Skip to main content

Queue

Struct Queue 

Source
pub struct Queue<A: Send + 'static> { /* private fields */ }
Expand description

Cloneable multi-producer / multi-consumer queue with several backpressure modes.

Implementations§

Source§

impl<A: Send + 'static> Queue<A>

Source

pub fn bounded(capacity: usize) -> Effect<Queue<A>, (), ()>

Bounded queue: Queue::offer returns false when full (no blocking).

Source

pub fn unbounded() -> Effect<Queue<A>, (), ()>

Unbounded queue.

Source

pub fn dropping(capacity: usize) -> Effect<Queue<A>, (), ()>

Bounded queue that drops the incoming element when full.

Source

pub fn sliding(capacity: usize) -> Effect<Queue<A>, (), ()>

Fixed-capacity queue that drops the oldest element when full.

Source

pub fn offer(&self, value: A) -> Effect<bool, (), ()>

Try to enqueue one value. false means the value was not stored (full, dropping, or shut down).

Source

pub fn offer_all<I>(&self, iter: I) -> Effect<Vec<A>, (), ()>
where I: IntoIterator<Item = A> + 'static, I::IntoIter: Send + 'static,

Enqueue as many values as possible; returns those that could not be stored (in order).

Source

pub fn take(&self) -> Effect<A, QueueError, ()>

Block until a value is available or the queue disconnects.

Source

pub fn take_all(&self) -> Effect<Chunk<A>, QueueError, ()>

Wait for at least one element, then drain all currently available elements.

Source

pub fn take_up_to(&self, n: usize) -> Effect<Chunk<A>, QueueError, ()>

After the first element arrives, take at most n elements total (including the first).

Source

pub fn take_n(&self, n: usize) -> Effect<Chunk<A>, QueueError, ()>

Block until n separate receives complete (or disconnect).

Source

pub fn take_between( &self, min: usize, max: usize, ) -> Effect<Chunk<A>, QueueError, ()>

Take between min and max elements inclusive (waits for min values unless disconnected).

Source

pub fn poll(&self) -> Effect<Option<A>, QueueError, ()>

Non-blocking receive.

Source

pub fn size(&self) -> Effect<usize, (), ()>

Queued element count (approximate for flume).

Source

pub fn is_empty(&self) -> Effect<bool, (), ()>

true when there are no queued elements.

Source

pub fn is_full(&self) -> Effect<bool, (), ()>

true when at capacity (bounded / sliding) or shut down (flume side).

Source

pub fn shutdown(&self) -> Effect<(), (), ()>

Close the queue to producers; buffered values remain available to receivers.

Source

pub fn is_shutdown(&self) -> Effect<bool, (), ()>

true after Self::shutdown has completed.

Source

pub fn await_shutdown(&self) -> Effect<(), (), ()>

Completes after Self::shutdown has been observed.

Trait Implementations§

Source§

impl<A: Send + 'static> Clone for Queue<A>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<A> Freeze for Queue<A>

§

impl<A> !RefUnwindSafe for Queue<A>

§

impl<A> Send for Queue<A>

§

impl<A> Sync for Queue<A>

§

impl<A> Unpin for Queue<A>

§

impl<A> UnsafeUnpin for Queue<A>

§

impl<A> !UnwindSafe for Queue<A>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pipe for T

Source§

fn pipe<F, R>(self, f: F) -> R
where F: FnOnce(Self) -> R,

Applies f to self (F#-style forward pipe).
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.