# ThreadBound

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/struct-threadbound/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct ThreadBound<T>
```

A value that stays on the thread that created it, inside an object that
is shared between threads.

A render resource is shared between the UI thread and the render thread,
yet some of them keep a part that only one of the threads uses (the
render target a render target bitmap draws itself with, for example).
The part is reached through `get`, which panics on any other
thread, so the object as a whole can be `Send + Sync`.

When the object is dropped on another thread the value is not dropped but
leaked: its destructor may only run on its own thread. Owners release
what the value holds from their `dispose`, on the right thread.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/thread_bound.rs#L16)

## Members

- [`new`](#function-new)
- [`is_on_thread`](#function-is_on_thread)
- [`get`](#function-get)
- [`into_inner`](#function-into_inner)

<a id="function-new"></a>

### new

```rust
fn new(value: T) -> Self
```

Binds `value` to the current thread.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/thread_bound.rs#L28)

<a id="function-is_on_thread"></a>

### is_on_thread

```rust
fn is_on_thread(self: &Self) -> bool
```

Whether the current thread is the one the value is bound to.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/thread_bound.rs#L33)

<a id="function-get"></a>

### get

```rust
fn get(self: &Self) -> &T
```

The value.
## Panics

On a thread other than the one the value was created on.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/thread_bound.rs#L42)

<a id="function-into_inner"></a>

### into_inner

```rust
fn into_inner(self: Self) -> T
```

Takes the value out.
## Panics

On a thread other than the one the value was created on.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/thread_bound.rs#L52)

## Trait implementations

- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Send`
- `Sync`
- `Drop`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
