pub struct Slot<T: Copy> { /* private fields */ }Expand description
A value that can be loaded and stored without locking.
Loads and a store can run concurrently.
There may be up to Self::MAX_READERS_COUNT concurrent loads but only single concurrent store allowed.
You can think of slot as of SPMC atomic varible but for non-atomic types.
Implemented using a triple-buffer.
Implementations§
Source§impl<T: Copy> Slot<T>
impl<T: Copy> Slot<T>
pub const MAX_READERS_COUNT: usize = State::MAX_READERS_COUNT
pub const fn new(value: T) -> Self
Sourcepub fn load(&self) -> T
pub fn load(&self) -> T
On success returns stored value.
- If there is no concurrent load takes place then the most recent value is returned
- If there are concurring loads then the same value is returned by all of them.
pub fn store(&self, value: T) -> Result<(), SlotStoreError>
Trait Implementations§
impl<T: Copy + Send> Send for Slot<T>
impl<T: Copy + Send> Sync for Slot<T>
Auto Trait Implementations§
impl<T> !Freeze for Slot<T>
impl<T> !RefUnwindSafe for Slot<T>
impl<T> Unpin for Slot<T>where
T: Unpin,
impl<T> UnwindSafe for Slot<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