Struct OwnedGuard

Source
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<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Guard for OwnedGuard<'_>

Source§

fn protect<T>(&self, ptr: &AtomicPtr<T>, _: Ordering) -> *mut T
where 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,

Retires a value, running reclaim when no threads hold a reference to it.

Source§

fn refresh(&mut self)

Refreshes the guard.

Source§

fn flush(&self)

Flush any retired values in the local batch.

Source§

fn thread_id(&self) -> usize

Returns a numeric identifier for the current thread.

Source§

fn belongs_to(&self, collector: &Collector) -> bool

Returns true if this guard belongs to the given collector.

Create a Link that can be used to link an object to the collector. Read more
Source§

impl Send for OwnedGuard<'_>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.