pub struct OwnedGuard<'a> { /* private fields */ }
Expand description
A guard that protects objects for it’s lifetime, independent of the current thread.
Unlike LocalGuard
, an owned guard is independent of the current thread,
allowing them to implement Send
. This is useful for holding guards across
.await
points in work-stealing schedulers, where execution may be resumed
on a different thread than started on. However, owned guards are more
expensive to create and destroy, so should be avoided if cross-thread usage
is not required.
Most of the functionality provided by this type is through the Guard
trait.
Trait Implementations§
Source§impl Drop for OwnedGuard<'_>
impl Drop for OwnedGuard<'_>
Source§impl Guard for OwnedGuard<'_>
impl Guard for OwnedGuard<'_>
Source§fn protect<T>(&self, ptr: &AtomicPtr<T>, _: Ordering) -> *mut Twhere
T: AsLink,
fn protect<T>(&self, ptr: &AtomicPtr<T>, _: Ordering) -> *mut Twhere
T: AsLink,
Protects the load of an atomic pointer.
Source§unsafe fn defer_retire<T>(&self, ptr: *mut T, reclaim: unsafe fn(_: *mut Link))where
T: AsLink,
unsafe fn defer_retire<T>(&self, ptr: *mut T, reclaim: unsafe fn(_: *mut Link))where
T: AsLink,
Retires a value, running reclaim
when no threads hold a reference to
it.
Source§fn belongs_to(&self, collector: &Collector) -> bool
fn belongs_to(&self, collector: &Collector) -> bool
Returns true
if this guard belongs to the given collector.
impl Send for OwnedGuard<'_>
impl Sync for OwnedGuard<'_>
Auto Trait Implementations§
impl<'a> Freeze for OwnedGuard<'a>
impl<'a> !RefUnwindSafe for OwnedGuard<'a>
impl<'a> Unpin for OwnedGuard<'a>
impl<'a> !UnwindSafe for OwnedGuard<'a>
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