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
impl AutoIpc
Sourcepub fn new(path: impl Into<PathBuf>) -> Self
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.
Sourcepub fn batch_size(self, k: usize) -> Self
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.
Sourcepub fn idle_wait(self, on: bool) -> Self
pub fn idle_wait(self, on: bool) -> Self
Hint that consumers should idle-wait between batches (WAITPKG on capable silicon; PAUSE-spin otherwise).
Sourcepub fn capacity(self, n: usize) -> Self
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.
Sourcepub fn ordering(self, ordering: Ordering) -> Self
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.
Sourcepub fn auto_order(self, threshold: f64) -> Self
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.
Sourcepub fn inferred_shape(&self) -> MmfWorkloadShape
pub fn inferred_shape(&self) -> MmfWorkloadShape
Infer the workload shape from the declared hints.
Sourcepub fn inferred_family(&self) -> MmfFamily
pub fn inferred_family(&self) -> MmfFamily
Inferred family pick (informational; no construction).
Sourcepub fn build_channel<T: Marshal>(self) -> Result<Channel<T>, ApiError>
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).
Sourcepub fn build_work_steal_queue<T: Marshal + Copy + 'static>(
self,
) -> Result<WorkStealQueue<T>, ApiError>
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).
Sourcepub fn build_adaptive<T: Marshal + Copy + 'static>(
self,
) -> Result<AdaptiveIpc<T>, ApiError>
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.
Sourcepub fn build_kv_map<K, V>(self) -> Result<KvMap<K, V>, ApiError>
pub fn build_kv_map<K, V>(self) -> Result<KvMap<K, V>, ApiError>
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).