Skip to main content

EventQueue

Struct EventQueue 

Source
pub struct EventQueue<T> { /* private fields */ }
Expand description

A bounded FIFO of pending events.

Every core in this crate hands events to the application through one of these. The bound matters: a 4.8 kHz sampled-value stream, or a publisher whose frames nobody collects, would otherwise grow an unbounded queue in a process that has stopped draining it. When the queue is full the oldest event is dropped — the newest state is the one that matters for protection — and EventQueue::dropped counts what was lost so the application can tell a quiet system from one it is not keeping up with.

Implementations§

Source§

impl<T> EventQueue<T>

Source

pub fn new(capacity: usize) -> Self

A queue holding at most capacity events (at least one).

Source

pub fn push(&mut self, item: T)

Append an event, dropping the oldest if the queue is full.

Source

pub fn pop(&mut self) -> Option<T>

Take the oldest event.

Source

pub const fn dropped(&self) -> u64

Number of events dropped because the application was not draining.

Source

pub fn len(&self) -> usize

Events waiting.

Source

pub fn is_empty(&self) -> bool

True when nothing is waiting.

Trait Implementations§

Source§

impl<T: Debug> Debug for EventQueue<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Forget for EventQueue<T>

§

impl<T> Freeze for EventQueue<T>
where *const u8 is !null: Freeze, PhantomData<T>: Freeze,

§

impl<T> Move for EventQueue<T>

§

impl<T> RefUnwindSafe for EventQueue<T>
where T: RefUnwindSafe,

§

impl<T> Send for EventQueue<T>
where T: Send, RawVecInner: Send,

§

impl<T> Sync for EventQueue<T>
where T: Sync, RawVecInner: Sync,

§

impl<T> Unpin for EventQueue<T>
where T: Unpin, *const u8 is !null: Unpin,

§

impl<T> UnsafeUnpin for EventQueue<T>

§

impl<T> UnwindSafe for EventQueue<T>
where RawVecInner: UnwindSafe, T: UnwindSafe,

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.