ThreadBound
struct · ferroui-base · v0.5.0
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.
Members
new
fn new(value: T) -> Self
Binds value to the current thread.
is_on_thread
fn is_on_thread(self: &Self) -> bool
Whether the current thread is the one the value is bound to.
get
fn get(self: &Self) -> &T
The value.
Panics
On a thread other than the one the value was created on.
into_inner
fn into_inner(self: Self) -> T
Takes the value out.
Panics
On a thread other than the one the value was created on.
Trait implementations
FreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeClassDefaultsBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyErasedDestructorIntoEitherSendSyncDrop
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.