pub struct AtomicEager<B: BackoffStrategy = NoBackoff, P: Parker = DefaultParker, PB: BoundedBackoffStrategy = DefaultSpinBeforePark> { /* private fields */ }Expand description
Nodes are pushed atomically to the back of the list and link themselves to the previous node eagerly.
A thread walking the list, e.g. to unlink its front node, may have to wait for a concurrent push
to link its node. Waiting is synchronized using the Parker P, and is preceded with a spin
loop bounded by PB.
On the platforms supported by the default AtomicParker, node push is lock-free. Otherwise, as
the pusher thread might unpark a remover thread, the lock-freedom is bounded by the unparking
operation.
Node push uses a CAS loop on the list state, followed by a second atomic RMW. Removal of the
back node, or list drain, requires a single RMW on the list state (in addition to the mutex
locking and unlocking). With a SpinParker that
never blocks, the second atomic RMW on push is replaced by an atomic
store.
As parking is necessary for soundness, unwinding in Parker methods causes the process to
abort.
B is the backoff strategy used on contention when pushing nodes or updating the list state.