Skip to main content

ArrayLinks

Struct ArrayLinks 

Source
pub struct ArrayLinks<const N: usize> { /* private fields */ }
Expand description

An owned [AtomicU32; N] link backing (used inside the fused ArrayIndexStack; slot-resident implementors host their own links instead). Every link starts at 0 — matching OS-zeroed backing — and is only ever written by a push (no eager free-list chaining).

Each link is a 4-byte AtomicU32, so 16 consecutive indices share one 64-byte cache line. If indices from the same 16-index group are handed to different threads under contention, this array becomes a SECOND contended surface alongside the stack’s own head — contended by accident of index numbering, not by design. Fix it at the CALLER when a profile shows it: wrap the index-to-link mapping so contended indices land in different groups, use a #[repr(align(64))] newtype per link, or — this crate’s own README’s recommendation for production — host links slot-resident inside a larger per-slot struct. Do NOT pad ArrayLinks itself to one link per cache line: that would multiply its footprint 16x for every single-threaded (or contention-indifferent) caller.

Implementations§

Source§

impl<const N: usize> ArrayLinks<N>

Source

pub const fn new() -> Self

Construct N links, every one at 0. NOT a bulk free-list init — links only become meaningful once their index is pushed. Under --cfg loom this cannot be const (loom’s atomics have no const ctor).

Source

pub fn load_next(&self, index: u32) -> u32

Load the “next” link for index with Acquire ordering.

This Acquire — and store_next’s Release — is deliberately retained rather than weakened to Relaxed, which the stack’s own head-publication proof would permit: defence-in-depth, see StackStorage’s “Ordering contract”.

§Panics

Panics if index >= N; the owned stack also checks this backing bound after its head-word range check.

Source

pub fn store_next(&self, index: u32, next: u32)

Store the “next” link for index with Release ordering. This is the ONLY write the stack makes to link storage, and only during a push — the lazy-link discipline: link storage is never eagerly initialised. Like load_next’s Acquire, this Release is deliberate defence-in-depth, not a stack-proof requirement — see StackStorage’s “Ordering contract”.

§Panics

Panics if index >= N — the same bound as load_next.

Trait Implementations§

Source§

impl<const N: usize> Debug for ArrayLinks<N>

Source§

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

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

impl<const N: usize> Default for ArrayLinks<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const N: usize> !Freeze for ArrayLinks<N>

§

impl<const N: usize> RefUnwindSafe for ArrayLinks<N>

§

impl<const N: usize> Send for ArrayLinks<N>
where [Atomic<u32>; N]: Send,

§

impl<const N: usize> Sync for ArrayLinks<N>
where [Atomic<u32>; N]: Sync,

§

impl<const N: usize> Unpin for ArrayLinks<N>
where [Atomic<u32>; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for ArrayLinks<N>
where [Atomic<u32>; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for ArrayLinks<N>
where [Atomic<u32>; N]: UnwindSafe,

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.