pub struct ThreadBound<T> { /* private fields */ }Expand description
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.
Implementations§
Source§impl<T> ThreadBound<T>
impl<T> ThreadBound<T>
Sourcepub fn is_on_thread(&self) -> bool
pub fn is_on_thread(&self) -> bool
Whether the current thread is the one the value is bound to.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Trait Implementations§
Source§impl<T> Drop for ThreadBound<T>
impl<T> Drop for ThreadBound<T>
impl<T> Send for ThreadBound<T>
impl<T> Sync for ThreadBound<T>
Auto Trait Implementations§
impl<T> Freeze for ThreadBound<T>where
ManuallyDrop<T>: Freeze,
impl<T> RefUnwindSafe for ThreadBound<T>where
ManuallyDrop<T>: RefUnwindSafe,
impl<T> Unpin for ThreadBound<T>where
ManuallyDrop<T>: Unpin,
impl<T> UnsafeUnpin for ThreadBound<T>where
ManuallyDrop<T>: UnsafeUnpin,
impl<T> UnwindSafe for ThreadBound<T>where
ManuallyDrop<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
The static constructor of a type: work done once per thread, after
the properties of the type are registered and before its first
instance exists (class handlers,
affects_render, metadata
overrides). Read more