Struct wgpu_core::snatch::Snatchable
source · pub struct Snatchable<T> {
value: UnsafeCell<Option<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<Option<T>>
Implementations§
source§impl<T> Snatchable<T>
impl<T> Snatchable<T>
pub fn new(val: T) -> Self
pub fn empty() -> Self
sourcepub fn get<'a>(&'a self, _guard: &'a SnatchGuard<'_>) -> Option<&'a T>
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.
sourcepub fn snatch(&self, _guard: &mut ExclusiveSnatchGuard<'_>) -> Option<T>
pub fn snatch(&self, _guard: &mut ExclusiveSnatchGuard<'_>) -> Option<T>
Take the value. Requires a the snatchable lock’s write guard.
Trait Implementations§
source§impl<T> Debug for Snatchable<T>
impl<T> Debug for Snatchable<T>
impl<T> Sync for Snatchable<T>
Auto Trait Implementations§
impl<T> !Freeze for Snatchable<T>
impl<T> !RefUnwindSafe for Snatchable<T>
impl<T> Send for Snatchable<T>where
T: Send,
impl<T> Unpin for Snatchable<T>where
T: Unpin,
impl<T> UnwindSafe for Snatchable<T>where
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