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, Token, Idx>(&self, _token: &'b Token) -> &'b Twhere
Token: LockTokenRead<Class, Idx>,
pub unsafe fn get<'b, Token, Idx>(&self, _token: &'b Token) -> &'b Twhere
Token: LockTokenRead<Class, Idx>,
Access the guarded value immutably using a shared lock token.
§Safety
The caller must guarantee that the provided LockToken belongs to the specific lock
instance that guards this KCell (rather than a different lock of the same lock class
Class).
Sourcepub unsafe fn get_mut<'b, Token, Idx>(&self, _token: &'b mut Token) -> &'b mut Twhere
Token: LockTokenWrite<Class, Idx>,
pub unsafe fn get_mut<'b, Token, Idx>(&self, _token: &'b mut Token) -> &'b mut Twhere
Token: LockTokenWrite<Class, Idx>,
Access the guarded value mutably using a mutable lock token.
§Safety
The caller must guarantee that the provided LockToken belongs to the specific lock
instance that guards this KCell (rather than a different lock of the same lock class
Class).
Sourcepub unsafe fn get_pinned_mut_locked<'b, Token, Idx>(
&self,
token: &'b mut Token,
) -> Pin<&'b mut T>where
Token: LockTokenWrite<Class, Idx>,
pub unsafe fn get_pinned_mut_locked<'b, Token, Idx>(
&self,
token: &'b mut Token,
) -> Pin<&'b mut T>where
Token: LockTokenWrite<Class, Idx>,
Access the guarded value as a pinned mutable reference using a mutable lock token.
§Safety
The caller must guarantee that the provided LockToken belongs to the specific lock
instance that guards this KCell (rather than a different lock of the same lock class
Class), and that this KCell is pinned in memory so its inner value is never moved.
Sourcepub unsafe fn as_ptr<Token, Idx>(&self, _token: &Token) -> *const Twhere
Token: LockTokenRead<Class, Idx>,
pub unsafe fn as_ptr<Token, Idx>(&self, _token: &Token) -> *const Twhere
Token: LockTokenRead<Class, Idx>,
Returns a const raw pointer to the guarded value.
§Safety
The caller must guarantee that a lock instance guarding this KCell is held continuously
while dereferencing or accessing the returned raw pointer.
Sourcepub unsafe fn as_mut_ptr<Token, Idx>(&self, _token: &mut Token) -> *mut Twhere
Token: LockTokenWrite<Class, Idx>,
pub unsafe fn as_mut_ptr<Token, Idx>(&self, _token: &mut Token) -> *mut Twhere
Token: LockTokenWrite<Class, Idx>,
Returns a mutable raw pointer to the guarded value.
§Safety
The caller must guarantee that the lock instance(s) guarding this KCell are 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 get_pinned_mut(self: Pin<&mut Self>) -> Pin<&mut T>
pub fn get_pinned_mut(self: Pin<&mut Self>) -> Pin<&mut T>
Projects a pinned reference to the cell to a pinned reference to the inner value.
Sourcepub fn init<I, E>(init: I) -> impl Init<Self, E>where
I: Init<T, E>,
pub fn init<I, E>(init: I) -> impl Init<Self, E>where
I: Init<T, E>,
Initializes a KCell in place with an Init initializer for its inner value.
Sourcepub fn pin_init<I, E>(init: I) -> impl PinInit<Self, E>where
I: PinInit<T, E>,
pub fn pin_init<I, E>(init: I) -> impl PinInit<Self, E>where
I: PinInit<T, E>,
Initializes a KCell with a PinInit initializer for its inner value.
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> Init<KCell<T, Class>, E> for KCellInit<I, Class>where
I: Init<T, E>,
impl<T, Class, I, E> Init<KCell<T, Class>, E> for KCellInit<I, Class>where
I: Init<T, E>,
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>,
Source§unsafe fn __pinned_init(self, slot: *mut KCell<T, Class>) -> Result<(), E>
unsafe fn __pinned_init(self, slot: *mut KCell<T, Class>) -> Result<(), E>
slot. Read moreSource§fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
self then calls the function f with the initialized
value. Read moreimpl<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>where
UnsafeCell<T>: Unpin,
PhantomData<Class>: Unpin,
impl<T, Class> UnsafeUnpin for KCell<T, Class>where
UnsafeCell<T>: UnsafeUnpin,
PhantomData<Class>: UnsafeUnpin,
impl<T, Class> UnwindSafe for KCell<T, Class>where
UnsafeCell<T>: UnwindSafe,
PhantomData<Class>: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§impl<T> PinInit<T> for T
impl<T> PinInit<T> for T
Source§unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>
unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>
slot. Read moreSource§fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>where
F: FnOnce(Pin<&mut T>) -> Result<(), E>,
self then calls the function f with the initialized
value. Read more