pub struct KCell<T, Class> { /* private fields */ }Expand description
A container cell that safe-guards data of type T using type-level lock class tracking.
KCell holds data that can only be safely accessed (read or written) by proving that the
corresponding mutual exclusion lock of class Class is currently held by the current thread
via a LockToken.
Implementations§
Source§impl<T, Class> KCell<T, Class>
impl<T, Class> KCell<T, Class>
Sourcepub unsafe fn get<'b>(&self, _token: &'b LockToken<'_, Class>) -> &'b T
pub unsafe fn get<'b>(&self, _token: &'b LockToken<'_, Class>) -> &'b T
Access the guarded value immutably using a shared lock token.
§Safety
The caller must guarantee that:
- The provided
LockTokenbelongs to the specific lock instance that guards thisKCell(rather than a different lock of the same lock classClass). - The lock is held continuously for the lifetime of the returned reference
'b.
Sourcepub unsafe fn get_mut<'b>(
&self,
_token: &'b mut LockToken<'_, Class>,
) -> &'b mut T
pub unsafe fn get_mut<'b>( &self, _token: &'b mut LockToken<'_, Class>, ) -> &'b mut T
Access the guarded value mutably using a mutable lock token.
§Safety
The caller must guarantee that:
- The provided
LockTokenbelongs to the specific lock instance that guards thisKCell(rather than a different lock of the same lock classClass). - The lock is held continuously for the lifetime of the returned reference
'b.
Sourcepub unsafe fn as_mut_ptr(&self, _token: &mut LockToken<'_, Class>) -> *mut T
pub unsafe fn as_mut_ptr(&self, _token: &mut LockToken<'_, Class>) -> *mut T
Returns a mutable raw pointer to the guarded value.
§Safety
The caller must guarantee that the lock instance guarding this KCell is held continuously
while dereferencing or accessing the returned raw pointer.
Sourcepub fn get_inner_mut(&mut self) -> &mut T
pub fn get_inner_mut(&mut self) -> &mut T
Accesses the inner value mutably by bypassing the locking requirements using unique borrow ownership.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwraps the cell, returning the inner value.
Trait Implementations§
Source§impl<T, Class, I, E> PinInit<KCell<T, Class>, E> for KCellInit<I, Class>where
I: PinInit<T, E>,
impl<T, Class, I, E> PinInit<KCell<T, Class>, E> for KCellInit<I, Class>where
I: PinInit<T, E>,
impl<T: Send, Class> Send for KCell<T, Class>
impl<T: Send, Class> Sync for KCell<T, Class>
Auto Trait Implementations§
impl<T, Class> !Freeze for KCell<T, Class>
impl<T, Class> !RefUnwindSafe for KCell<T, Class>
impl<T, Class> Unpin for KCell<T, Class>
impl<T, Class> UnsafeUnpin for KCell<T, Class>where
T: UnsafeUnpin,
impl<T, Class> UnwindSafe for KCell<T, Class>where
T: UnwindSafe,
Class: 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
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), Infallible>
slot. Read more