Skip to main content

SharedDequeKhpd

Struct SharedDequeKhpd 

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

MMF-backed K-axis Hierarchical Publication Deque. Single owner, arbitrarily many thieves.

Implementations§

Source§

impl SharedDequeKhpd

Source

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.

Source

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

Open an existing KHPD file.

Source

pub fn capacity(&self) -> usize

Capacity in publication lines (always a power of two).

Source

pub fn owner_pid(&self) -> u64

Owner pid at create time, or 0 after close_owner().

Source

pub fn close_owner(&self)

Advance epoch + zero the owner pid on shutdown.

Source

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

Snapshot (head, tail, ring_size_lines, pending_items).

Source

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.

Source

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.

Source

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.

Source

pub fn steal_line(&self) -> Steal

Thief-side. Claim one publication line.

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.