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§
Sourcepub fn create<P: AsRef<Path>>(
path: P,
capacity: usize,
flush_threshold: usize,
) -> Result<Self>
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.
Sourcepub fn open<P: AsRef<Path>>(path: P, flush_threshold: usize) -> Result<Self>
pub fn open<P: AsRef<Path>>(path: P, flush_threshold: usize) -> Result<Self>
Open an existing LOH file. Validates magic and capacity.
Sourcepub fn flush_threshold(&self) -> usize
pub fn flush_threshold(&self) -> usize
Configured auto-flush threshold (LIFO length that triggers a flush on the next push).
Sourcepub fn close_owner(&self)
pub fn close_owner(&self)
Owner shutdown: zero pid + advance epoch.
Sourcepub fn snapshot_size(&self) -> (i64, i64, i64, usize)
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.
Sourcepub fn push(&self, item: LineItem) -> Result<(), PushError>
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.
Sourcepub fn flush(&self) -> Result<usize, PushError>
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.
Sourcepub fn publish_batch(&self, items: &[LineItem]) -> Result<usize, PushError>
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.
Sourcepub fn pop_local(&self) -> Option<LineItem>
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.
Sourcepub fn steal(&self) -> Steal
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.
Sourcepub fn flush_to_disk(&self) -> Result<()>
pub fn flush_to_disk(&self) -> Result<()>
Force any dirty pages to disk.