Skip to main content

KhlSlot

Struct KhlSlot 

Source
#[repr(C, align(64))]
pub struct KhlSlot { pub packed_sequence: AtomicI64, pub _reserved: u64, pub items: [LineItem; 3], }
Expand description

Ring slot: Vyukov sequence (with n_items bit-packed into the low 2 bits) + 3 LineItem payloads. Fixed shape, 64 bytes, process-portable.

§Cross-axis fusion: n_items packed into sequence

n_items is always in 1..=KHL_ITEMS_PER_SLOT = 3, which fits in 2 bits. Instead of paying a separate store to publish n_items alongside the sequence number, we encode it in the low 2 bits of packed_sequence. The producer’s ONE Release-store on packed_sequence publishes BOTH the protocol state AND the payload count - saving one store per slot, which fuses the K_inner axis (items per slot) with the K_gating axis (per-slot atomic) at the slot’s cache line.

Encoding:

  • idx_value = high 62 bits of packed_sequence
  • n_items = low 2 bits of packed_sequence
  • State: idx_value == idx (empty) -> idx_value == idx + 1 (published, n_items valid) -> idx_value == idx + capacity (consumed)

Fields§

§packed_sequence: AtomicI64

Bit-packed Vyukov sequence: (idx_value << 2) | n_items.

§_reserved: u64

Reserved 8 bytes for cache-line alignment of the items array (items start at offset 16, slot is 64 bytes total).

§items: [LineItem; 3]

Caller’s byte-oriented payloads. Only the first unpack_n_items(packed_sequence.load()) are guaranteed valid.

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.