Consumer

Struct Consumer 

Source
pub struct Consumer<T, PO: Output + 'static, B> { /* private fields */ }
Expand description

A consumer of items from the queue

Implementations§

Source§

impl<T, PO: Output + 'static> Consumer<T, PO, SingleBarrier<PO>>

Source

pub fn new( ring: Arc<RingBuffer<T, PO>>, mode: ConsumerMode, ) -> Result<Self, TooManyConsumers>

Creates a new consumer that await for messages from all producers on a ring

§Errors

Fail when the ring reached the maximum number of consumers

Source§

impl<T, PO: Output + 'static> Consumer<T, PO, SingleBarrier<OwnedOutput>>

Source

pub fn new_awaiting_on<U: QueueUser<Item = T, UserOutput = OwnedOutput, ProducerOutput = PO>>( other: &U, mode: ConsumerMode, ) -> Result<Self, TooManyConsumers>

Creates a new consumer that awaits on a single other user, usually a consumer

§Errors

Fail when the ring reached the maximum number of consumers

Source§

impl<T, PO: Output + 'static> Consumer<T, PO, MultiBarrier<OwnedOutput>>

Source

pub fn new_awaiting_multiple<'u, I>( others: I, mode: ConsumerMode, ) -> Result<Self, TooManyConsumers>
where I: IntoIterator<Item = &'u dyn QueueUser<Item = T, UserOutput = OwnedOutput, ProducerOutput = PO>>, T: 'u,

Creates a new consumer that awaits on multiple other users, usually consumers

§Errors

Fail when the ring reached the maximum number of consumers

Source§

impl<T, PO: Output + 'static, B> Consumer<T, PO, B>

Source

pub fn blocking_mode(&self) -> ConsumerMode

Whether this consumer blocks producers By default, consumers block producers writing new items when they have not yet be seen. Setting a consumer as non-blocking enable producers to write event though the consumer may be lagging.

Source§

impl<T, PO: Output + 'static, B: Barrier> Consumer<T, PO, B>

Source

pub fn get_number_of_items(&self) -> usize

Gets the number of items in the queue accessible to this consumer

Source

pub fn try_recv(&mut self) -> Result<ConsumerAccess<'_, T, PO, B>, TryRecvError>

Attempts to receive available items from the queue

§Errors

This returns a TryRecvError when the queue is empty, or when there is no longer any producer

Source

pub fn try_recv_bounded( &mut self, max: usize, ) -> Result<ConsumerAccess<'_, T, PO, B>, TryRecvError>

Attempts to receive available items from the queue with a maximum number of items

§Errors

This returns a TryRecvError when the queue is empty, or when there is no longer any producer

Source

pub fn try_recv_copies( &mut self, buffer: &mut [T], ) -> Result<usize, TryRecvError>
where T: Copy,

Attempts to receive a single item from the queue

§Errors

This returns a TryRecvError when the queue is empty, or when there is no longer any producer

Trait Implementations§

Source§

impl<T, PO: Output + 'static, B: Clone> Clone for Consumer<T, PO, B>

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
Source§

impl<T: Debug, PO: Debug + Output + 'static, B: Debug> Debug for Consumer<T, PO, B>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T, PO: Output + 'static, B> Drop for Consumer<T, PO, B>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T, PO: Output + 'static, B> QueueUser for Consumer<T, PO, B>

Source§

type Item = T

The type of the queue items
Source§

type UserOutput = OwnedOutput

The type of output for this user
Source§

type ProducerOutput = PO

The type for the producer’s output
Source§

fn queue(&self) -> &Arc<RingBuffer<Self::Item, Self::ProducerOutput>>

Gets the queue itself
Source§

fn output(&self) -> &Arc<Self::UserOutput>

Gets the output that can be awaited on for items that are available after this user

Auto Trait Implementations§

§

impl<T, PO, B> Freeze for Consumer<T, PO, B>
where B: Freeze,

§

impl<T, PO, B> !RefUnwindSafe for Consumer<T, PO, B>

§

impl<T, PO, B> Send for Consumer<T, PO, B>
where B: Send, T: Sync + Send,

§

impl<T, PO, B> Sync for Consumer<T, PO, B>
where B: Sync, T: Sync + Send,

§

impl<T, PO, B> Unpin for Consumer<T, PO, B>
where B: Unpin,

§

impl<T, PO, B> !UnwindSafe for Consumer<T, PO, B>

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> 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.