Skip to main content

AutoIpc

Struct AutoIpc 

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

Builder for an auto-inferred IPC endpoint. The caller describes the workload with declarative hints; the builder infers the MmfWorkloadShape, asks MmfDispatcher for the family, and constructs the right typed-intent wrapper.

No workload shape, no family enum, no primitive choice ever touches the user. They write:

use subetha_cxc::AutoIpc;

let auto = AutoIpc::new("/tmp/auto-ipc.bin")
    .producers(4)
    .consumers(4)
    .batch_size(64)
    .capacity(1024)
    .build_channel::<u64>()
    .expect("create");
auto.send(&42).expect("send");

The builder picks streaming MPMC when there are multiple producers / consumers without a single-owner constraint; work-stealing when there is one producer and multiple consumers with a batch hint; key-value when the caller selects build_kv_map. The inference is zero-cost: it runs once at build_*, never per-op.

Implementations§

Source§

impl AutoIpc

Source

pub fn new(path: impl Into<PathBuf>) -> Self

Start a new auto-inferred IPC endpoint at path. Defaults: 1 producer, 1 consumer, no batch, capacity 64, per-producer ordering, no auto-order threshold.

Source

pub fn producers(self, n: usize) -> Self

Number of producers expected to push concurrently.

Source

pub fn consumers(self, n: usize) -> Self

Number of consumers expected to drain concurrently.

Source

pub fn batch_size(self, k: usize) -> Self

Hint that the producer will publish batches of k items. Setting this is what flips a single-producer streaming workload into work-stealing routing.

Source

pub fn idle_wait(self, on: bool) -> Self

Hint that consumers should idle-wait between batches (WAITPKG on capable silicon; PAUSE-spin otherwise).

Source

pub fn capacity(self, n: usize) -> Self

Ring slot capacity, clamped to >= 2 and rounded up to the next power of two. Every terminal’s backing store requires a pow2 capacity.

Source

pub fn ordering(self, ordering: Ordering) -> Self

Declare the ordering requirement. GlobalFifo constrains the inference to the streaming family (a work-stealing deque’s LIFO owner end cannot honor FIFO at all), and build_adaptive applies the declaration to the stamped ring’s merge flag.

Source

pub fn auto_order(self, threshold: f64) -> Self

Pre-authorize an automatic ordering response: when the built endpoint observes more than threshold cross-producer inversions per second, its sidecar arms global-FIFO delivery (the stamped merge) without a further declaration. Effective through build_adaptive, which constructs the stamped ring the response needs.

Source

pub fn inferred_shape(&self) -> MmfWorkloadShape

Infer the workload shape from the declared hints.

Source

pub fn inferred_family(&self) -> MmfFamily

Inferred family pick (informational; no construction).

Source

pub fn build_channel<T: Marshal>(self) -> Result<Channel<T>, ApiError>

Build a streaming MPMC channel for T: Marshal. Returns WrongFamily if the inferred shape resolves to something other than SharedRing (e.g. you set batch_size and the inference picked work-stealing).

Source

pub fn build_work_steal_queue<T: Marshal + Copy + 'static>( self, ) -> Result<WorkStealQueue<T>, ApiError>

Build a work-stealing queue. Returns WrongFamily if the inferred shape is not work-stealing (call batch_size to force work-stealing inference) or if GlobalFifo ordering was declared (a deque’s LIFO owner end cannot honor FIFO).

Source

pub fn build_adaptive<T: Marshal + Copy + 'static>( self, ) -> Result<AdaptiveIpc<T>, ApiError>

Build an AdaptiveIpc endpoint with the ordering axis wired through: the inner ring carries push stamps, the ordering declaration is applied at construction (GlobalFifo = stamped merge ON), and an auto_order threshold pre-authorizes the sidecar’s automatic arm on observed inversion rate.

Source

pub fn build_kv_map<K, V>(self) -> Result<KvMap<K, V>, ApiError>
where K: Copy + Eq + Hash + Send + Sync + 'static, V: Copy + Send + Sync + 'static,

Build a key-value map. The caller declares key-value intent by calling this method (key-value access doesn’t share signature axes with streaming / work-stealing).

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.