pub struct RingContract {
pub max_concurrent_push: u8,
pub max_concurrent_pop: u8,
pub ordering: OrderingContract,
pub capacity_bound: Option<u32>,
}Expand description
Declared operation envelope for a ring. The two count bounds use
0 to mean “unbounded”.
Fields§
§max_concurrent_push: u8Max concurrently-registered producers (0 = unbounded).
max_concurrent_pop: u8Max concurrently-registered consumers (0 = unbounded).
ordering: OrderingContractThe ordering envelope the consumers may observe.
capacity_bound: Option<u32>Optional hard ceiling on ring capacity (None = unbounded).
Implementations§
Source§impl RingContract
impl RingContract
Sourcepub fn from_counts(max_producers: usize, max_consumers: usize) -> Self
pub fn from_counts(max_producers: usize, max_consumers: usize) -> Self
A contract that PINS the peer counts: registration past
max_producers / max_consumers returns TooManyProducers /
TooManyConsumers instead of growing the ring. No ordering
constraint, no capacity bound. The common fixed-topology
declaration.
Sourcepub fn unbounded() -> Self
pub fn unbounded() -> Self
The fully-unbounded contract: any peer counts, any capacity, no ordering constraint. The DEFAULT for rings with no declared contract - registration never fails under it (peers grow the ring on demand up to the substrate slot ceilings).
Sourcepub fn permits_producer(&self, active: usize) -> bool
pub fn permits_producer(&self, active: usize) -> bool
May another producer attach, given active are registered?
Sourcepub fn permits_consumer(&self, active: usize) -> bool
pub fn permits_consumer(&self, active: usize) -> bool
May another consumer attach, given active are registered?
Sourcepub fn permits_capacity(&self, capacity: usize) -> bool
pub fn permits_capacity(&self, capacity: usize) -> bool
Is a ring of capacity slots legal under the contract?
Sourcepub fn permits_shape(&self, shape: RingShape) -> bool
pub fn permits_shape(&self, shape: RingShape) -> bool
Is shape legal under the ordering contract? Global total order
is preserved only by the single-stream Spsc
and the shared-sequence Vyukov; the
partitioned per-producer-lane shapes
(Mpsc, Mpmc) interleave
producers, so both are illegal under a Fifo contract. Every
other contract permits every shape (FifoPerProducer is exactly
what the lanes deliver).
Sourcepub fn permits_config(&self, shape: RingShape, capacity: usize) -> bool
pub fn permits_config(&self, shape: RingShape, capacity: usize) -> bool
Feasible-region oracle for an adaptive policy: is a candidate
(shape, capacity) configuration legal? A policy filters every
move it proposes through this, so an aggressive auto-morph
cannot violate the declared envelope.
Trait Implementations§
Source§impl Clone for RingContract
impl Clone for RingContract
Source§fn clone(&self) -> RingContract
fn clone(&self) -> RingContract
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more