Skip to main content

EventRing

Struct EventRing 

Source
pub struct EventRing<const N: usize> { /* private fields */ }
Expand description

A fixed-capacity SPSC ring of N slots (usable capacity N - 1).

Implementations§

Source§

impl<const N: usize> EventRing<N>

Source

pub fn new() -> Self

Create an empty ring. N must be at least 2 (one slot is a sentinel).

Source

pub const fn capacity(&self) -> usize

Usable capacity (one slot is reserved as the full/empty sentinel).

Source

pub fn push(&self, event: TimedEvent) -> Result<(), TimedEvent>

Producer side: enqueue an event. Returns the event back as Err if the ring is full. Wait-free and allocation-free.

Source

pub fn pop(&self) -> Option<TimedEvent>

Consumer side: dequeue the oldest event, or None if empty. Wait-free.

Source

pub fn is_empty(&self) -> bool

Whether the ring currently holds no events (consumer-side view).

Source

pub fn len(&self) -> usize

Number of events currently queued.

Trait Implementations§

Source§

impl<const N: usize> Default for EventRing<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const N: usize> Sync for EventRing<N>

Auto Trait Implementations§

§

impl<const N: usize> !Freeze for EventRing<N>

§

impl<const N: usize> !RefUnwindSafe for EventRing<N>

§

impl<const N: usize> Send for EventRing<N>

§

impl<const N: usize> Unpin for EventRing<N>

§

impl<const N: usize> UnsafeUnpin for EventRing<N>

§

impl<const N: usize> UnwindSafe for EventRing<N>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.