pub struct WorkerSlot<K, V> { /* private fields */ }Expand description
Per-worker exclusive slot holding a BatchBuf inside an UnsafeCell.
The WORKER_ID TLS invariant guarantees that only one thread ever accesses any given slot, eliminating the need for any synchronisation primitive on the insert hot-path (zero atomics, zero locks, pure memory write).
Implementations§
Source§impl<K, V> WorkerSlot<K, V>
impl<K, V> WorkerSlot<K, V>
pub fn new() -> Self
Sourcepub unsafe fn get_mut_unchecked(&self) -> &mut BatchBuf<K, V>
pub unsafe fn get_mut_unchecked(&self) -> &mut BatchBuf<K, V>
Provides exclusive access to the underlying buffer.
§Safety
The caller must guarantee that only one thread accesses this slot at a time. In DualCache-FF this is enforced by the WORKER_ID TLS invariant.
Sourcepub fn get_mut_safe(&self) -> &mut BatchBuf<K, V>
pub fn get_mut_safe(&self) -> &mut BatchBuf<K, V>
Safe accessor that encapsulates the unsafe block.
In DualCache-FF this is safe because it’s only called by the assigned worker thread.
Trait Implementations§
impl<K: Send, V: Send> Send for WorkerSlot<K, V>
impl<K: Send + Sync, V: Send + Sync> Sync for WorkerSlot<K, V>
Auto Trait Implementations§
impl<K, V> !Freeze for WorkerSlot<K, V>
impl<K, V> !RefUnwindSafe for WorkerSlot<K, V>
impl<K, V> Unpin for WorkerSlot<K, V>
impl<K, V> UnsafeUnpin for WorkerSlot<K, V>where
K: UnsafeUnpin,
V: UnsafeUnpin,
impl<K, V> UnwindSafe for WorkerSlot<K, V>where
K: UnwindSafe,
V: 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