pub struct ProcessSharedRing<T> { /* private fields */ }Expand description
Preallocated bounded ring used at process-site stream boundaries.
Implementations§
Sourcepub fn with_capacity(capacity: usize) -> Result<Self>
pub fn with_capacity(capacity: usize) -> Result<Self>
Creates a ring preallocated to hold capacity items.
Returns an evaluation error when capacity is zero.
§Examples
use sim_lib_stream_host::{ProcessRingPush, ProcessSharedRing};
let mut ring = ProcessSharedRing::with_capacity(2).unwrap();
assert_eq!(ring.try_push(1), ProcessRingPush::Accepted);
assert_eq!(ring.try_push(2), ProcessRingPush::Accepted);
assert_eq!(ring.try_push(3), ProcessRingPush::DroppedNewest(3));
assert_eq!(ring.try_pop(), Some(1));Sourcepub fn try_push(&mut self, item: T) -> ProcessRingPush<T>
pub fn try_push(&mut self, item: T) -> ProcessRingPush<T>
Pushes an item, returning whether it was accepted, dropped (full), or rejected (closed).
Sourcepub fn try_pop(&mut self) -> Option<T>
pub fn try_pop(&mut self) -> Option<T>
Pops the oldest item, or returns None when the ring is empty.
Sourcepub fn cancel(&mut self)
pub fn cancel(&mut self)
Drains all buffered items and closes the ring, recording cancellation.
Sourcepub fn allocated_slots(&self) -> usize
pub fn allocated_slots(&self) -> usize
Returns the number of slots backing storage has allocated.
Sourcepub fn snapshot(&self) -> ProcessRingSnapshot
pub fn snapshot(&self) -> ProcessRingSnapshot
Captures a capacity snapshot for steady-state checks.
Sourcepub fn stats(&self) -> StreamStats
pub fn stats(&self) -> StreamStats
Returns a clone of the ring’s running statistics.
Trait Implementations§
Source§fn clone(&self) -> ProcessSharedRing<T>
fn clone(&self) -> ProcessSharedRing<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more