pub struct SharedDequeKhpd { /* private fields */ }Expand description
MMF-backed K-axis Hierarchical Publication Deque. Single owner, arbitrarily many thieves.
Implementations§
Sourcepub fn create<P: AsRef<Path>>(path: P, capacity: usize) -> Result<Self>
pub fn create<P: AsRef<Path>>(path: P, capacity: usize) -> Result<Self>
Create a fresh KHPD file. capacity rounds up to the next
power of two; minimum 2.
Sourcepub fn close_owner(&self)
pub fn close_owner(&self)
Advance epoch + zero the owner pid on shutdown.
Sourcepub fn snapshot_size(&self) -> (i64, i64, i64, usize)
pub fn snapshot_size(&self) -> (i64, i64, i64, usize)
Snapshot (head, tail, ring_size_lines, pending_items).
Sourcepub fn stage(&self, item: LineItem) -> Result<usize, PushError>
pub fn stage(&self, item: LineItem) -> Result<usize, PushError>
Owner-side stage. Adds one item to the pending buffer.
Returns the running pending count (so the caller can decide
to flush at LINE_ITEMS). Only the owner process may
stage.
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. Bypasses the
stage/publish pair so the
caller pays only ONE Mutex acquire per batch instead of one
per staged item. This is the canonical hot-path API: the
caller hands in a slice of LineItem values and the method
publishes them into ceil(items.len() / LINE_ITEMS)
publication lines with one tail.fetch_add(n_lines) plus
one Release-store per line.
Returns the number of LINES published.
Sourcepub fn publish(&self) -> Result<usize, PushError>
pub fn publish(&self) -> Result<usize, PushError>
Owner-side publish. Drains the pending buffer into one or
more publication lines (LINE_ITEMS items per line). Each
line takes one tail.fetch_add(1) plus one Release-store on
the line’s state. Returns the number of LINES published.
Sourcepub fn steal_line(&self) -> Steal
pub fn steal_line(&self) -> Steal
Thief-side. Claim one publication line.
Sourcepub fn flush_to_disk(&self) -> Result<()>
pub fn flush_to_disk(&self) -> Result<()>
Force any dirty pages to disk.