Skip to main content

SharedDequeLoh

Struct SharedDequeLoh 

Source
pub struct SharedDequeLoh { /* private fields */ }
Expand description

MMF-backed LOH deque. Single owner (the process that created the file); arbitrarily many thieves across processes.

Implementations§

Source§

impl SharedDequeLoh

Source

pub fn create<P: AsRef<Path>>( path: P, capacity: usize, flush_threshold: usize, ) -> Result<Self>

Create a fresh LOH file. capacity rounds up to the next power of two (min 2). flush_threshold is the LIFO length at which an automatic Self::flush fires on the next push.

Source

pub fn open<P: AsRef<Path>>(path: P, flush_threshold: usize) -> Result<Self>

Open an existing LOH file. Validates magic and capacity.

Source

pub fn capacity(&self) -> usize

Slot count of the ring (always a power of two).

Source

pub fn flush_threshold(&self) -> usize

Configured auto-flush threshold (LIFO length that triggers a flush on the next push).

Source

pub fn owner_pid(&self) -> u64

Pid of the owner process at create time, or 0 if cleared.

Source

pub fn close_owner(&self)

Owner shutdown: zero pid + advance epoch.

Source

pub fn snapshot_size(&self) -> (i64, i64, i64, usize)

Snapshot the current (head, tail, ring_size, lifo_len). Loads are independent; the tuple is not a linearizable snapshot - useful for debug / introspection only.

Source

pub fn push(&self, item: LineItem) -> Result<(), PushError>

Owner-side push. Stages the item in the local LIFO; when the LIFO reaches flush_threshold an automatic Self::flush fires that drains the LIFO into the ring tail.

Only the owner process may call this.

Source

pub fn flush(&self) -> Result<usize, PushError>

Owner-side explicit flush. Drains the local LIFO into the ring’s tail in one batch (one tail.fetch_add(N) + N Release-stores). Returns the number of items migrated.

Source

pub fn publish_batch(&self, items: &[LineItem]) -> Result<usize, PushError>

Owner-side single-call batch publish. Holds zero locks. The LIFO-bypass property is the SubEtha-native lever: the upstream LCRQ-on-LIFO design held a Mutex during batch publish to satisfy a separate dispatch-backend &self contract; SubEtha’s owner-only protocol makes that Mutex gratuitous on the batch path. tail.fetch_add(N) atomically reserves a disjoint slot range; the per-slot sequence-number protocol gates the writes. A sibling flush() or push() touching the LIFO is independent: it competes only on tail.fetch_add, not on the LIFO Vec.

Cost per call: one tail.fetch_add(items.len()) plus items.len() per-slot Release-stores on the sequence number.

Returns the number of items migrated.

Source

pub fn pop_local(&self) -> Option<LineItem>

Owner-side pop from the local LIFO. Items still in the LIFO (unmigrated) may be retrieved locally without round-tripping through the ring.

Source

pub fn steal(&self) -> Steal

Thief-side steal. Race-free CAS-on-head with sequence-number validation on the slot. Returns Steal::Retry when a competing thief beat us on the head CAS, or when the publisher’s Release on the sequence number is missing from the slot snapshot; outer loop should retry.

Source

pub fn flush_to_disk(&self) -> Result<()>

Force any dirty pages to disk.

Trait Implementations§

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.