Skip to main content

LossyQueue

Struct LossyQueue 

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

MPSC wait-free lossy ring buffer.

Implementations§

Source§

impl<T> LossyQueue<T>

Source

pub fn new(capacity: usize) -> Self

Create a new queue with the given capacity (must be a power of two).

Source

pub fn try_send(&self, item: T) -> Result<(), T>

Worker path — try to enqueue an item.

Uses FAA to claim a slot index, then CAS EMPTY→WRITING as a physical gate. If the slot is occupied (ring buffer lapped or concurrent writer), returns Err(item) immediately — never blocks.

Source

pub fn send_blocking(&self, item: T)

Blocking send for critical commands (Sync, Clear). Spins until the item is successfully enqueued.

Source

pub fn try_recv(&self) -> Option<T>

Daemon path — try to dequeue one item.

Single-consumer: only Daemon ever calls this. Reads from head, returns None if the slot is not yet READY.

Trait Implementations§

Source§

impl<T> Drop for LossyQueue<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: Send> Send for LossyQueue<T>

Source§

impl<T: Send> Sync for LossyQueue<T>

Auto Trait Implementations§

§

impl<T> !Freeze for LossyQueue<T>

§

impl<T> !RefUnwindSafe for LossyQueue<T>

§

impl<T> Unpin for LossyQueue<T>

§

impl<T> UnsafeUnpin for LossyQueue<T>

§

impl<T> UnwindSafe for LossyQueue<T>
where 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.