SnatchableInner

Struct SnatchableInner 

Source
pub struct SnatchableInner<T> {
    value: UnsafeCell<T>,
}
Expand description

A value that is mostly immutable but can be “snatched” if we need to destroy it early.

In order to safely access the underlying data, the device’s global snatchable lock must be taken. To guarantee it, methods take a read or write guard of that special lock.

Fields§

§value: UnsafeCell<T>

Implementations§

Source§

impl<T> SnatchableInner<Option<T>>

Source

pub fn new(val: T) -> Self

Source

pub fn empty() -> Self

Source

pub fn get<'a>(&'a self, _guard: &'a SnatchGuard<'_>) -> Option<&'a T>

Get read access to the value. Requires a the snatchable lock’s read guard.

Source

pub fn snatch(&self, _guard: &mut ExclusiveSnatchGuard<'_>) -> Option<T>

Take the value. Requires a the snatchable lock’s write guard.

Source

pub fn take(&mut self) -> Option<T>

Take the value without a guard. This can only be used with exclusive access to self, so it does not require locking.

Typically useful in a drop implementation.

Trait Implementations§

Source§

impl<T> Debug for SnatchableInner<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Sync for SnatchableInner<T>

Auto Trait Implementations§

§

impl<T> !Freeze for SnatchableInner<T>

§

impl<T> !RefUnwindSafe for SnatchableInner<T>

§

impl<T> Send for SnatchableInner<T>
where T: Send,

§

impl<T> Unpin for SnatchableInner<T>
where T: Unpin,

§

impl<T> UnwindSafe for SnatchableInner<T>
where T: UnwindSafe,

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,