pub(crate) struct Inner<T: 'static> {
head: AtomicU64,
tail: AtomicU32,
lifo: AtomicNotified<T>,
buffer: Box<[UnsafeCell<MaybeUninit<Notified<T>>>; 256]>,
}Fields§
§head: AtomicU64Concurrently updated by many threads.
Contains two UnsignedShort values. The LSB byte is the “real” head of
the queue. The UnsignedShort in the MSB is set by a stealer in process
of stealing values. It represents the first value being stolen in the
batch. The UnsignedShort indices are intentionally wider than strictly
required for buffer indexing in order to provide ABA mitigation and make
it possible to distinguish between full and empty buffers.
When both UnsignedShort values are the same, there is no active
stealer.
Tracking an in-progress stealer prevents a wrapping scenario.
tail: AtomicU32Only updated by producer thread but read by many threads.
lifo: AtomicNotified<T>When a task is scheduled from a worker, it is stored in this slot. The worker will check this slot for a task before checking the run queue. This effectively results in the last scheduled task to be run next (LIFO). This is an optimization for improving locality which benefits message passing patterns and helps to reduce latency.
buffer: Box<[UnsafeCell<MaybeUninit<Notified<T>>>; 256]>Elements