Skip to main content

AtomicEager

Struct AtomicEager 

Source
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.

Trait Implementations§

Source§

impl<B: Debug + BackoffStrategy, P: Debug + Parker, PB: Debug + BoundedBackoffStrategy> Debug for AtomicEager<B, P, PB>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B: BackoffStrategy, P: Parker, PB: BoundedBackoffStrategy> Linking for AtomicEager<B, P, PB>

Auto Trait Implementations§

§

impl<B, P, PB> Freeze for AtomicEager<B, P, PB>

§

impl<B, P, PB> RefUnwindSafe for AtomicEager<B, P, PB>

§

impl<B, P, PB> Send for AtomicEager<B, P, PB>

§

impl<B, P, PB> Sync for AtomicEager<B, P, PB>

§

impl<B, P, PB> Unpin for AtomicEager<B, P, PB>

§

impl<B, P, PB> UnsafeUnpin for AtomicEager<B, P, PB>

§

impl<B, P, PB> UnwindSafe for AtomicEager<B, P, PB>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.