pub struct ThreadAffinity { /* private fields */ }Expand description
A synchronization primitive that tracks thread affinity.
It provides mechanisms to attach an object to a thread and assert that
the object is or is not attached to the current thread. When the feature
detect_lock_dep_cycles is disabled, this struct and its methods are zero-cost.
Implementations§
Source§impl ThreadAffinity
impl ThreadAffinity
pub const fn new() -> Self
Sourcepub fn attach(&self) -> ThreadAffinityGuard<'_>
pub fn attach(&self) -> ThreadAffinityGuard<'_>
Attaches this object to the current thread.
Returns a ThreadAffinityGuard that will detach the object when dropped.
Sourcepub fn assert_attached(&self)
pub fn assert_attached(&self)
Asserts that this object is attached to the current thread.
Panics if it is not attached.
Sourcepub fn assert_not_attached(&self)
pub fn assert_not_attached(&self)
Asserts that this object is NOT attached to the current thread.
Panics if it is attached.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ThreadAffinity
impl RefUnwindSafe for ThreadAffinity
impl Send for ThreadAffinity
impl Sync for ThreadAffinity
impl Unpin for ThreadAffinity
impl UnsafeUnpin for ThreadAffinity
impl UnwindSafe for ThreadAffinity
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