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>>
impl<T, PO: Output + 'static> Consumer<T, PO, SingleBarrier<PO>>
Sourcepub fn new(
ring: Arc<RingBuffer<T, PO>>,
mode: ConsumerMode,
) -> Result<Self, TooManyConsumers>
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>>
impl<T, PO: Output + 'static> Consumer<T, PO, SingleBarrier<OwnedOutput>>
Sourcepub fn new_awaiting_on<U: QueueUser<Item = T, UserOutput = OwnedOutput, ProducerOutput = PO>>(
other: &U,
mode: ConsumerMode,
) -> Result<Self, TooManyConsumers>
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>>
impl<T, PO: Output + 'static> Consumer<T, PO, MultiBarrier<OwnedOutput>>
Sourcepub 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,
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>
impl<T, PO: Output + 'static, B> Consumer<T, PO, B>
Sourcepub fn blocking_mode(&self) -> ConsumerMode
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>
impl<T, PO: Output + 'static, B: Barrier> Consumer<T, PO, B>
Sourcepub fn get_number_of_items(&self) -> usize
pub fn get_number_of_items(&self) -> usize
Gets the number of items in the queue accessible to this consumer
Sourcepub fn try_recv(&mut self) -> Result<ConsumerAccess<'_, T, PO, B>, TryRecvError>
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
Sourcepub fn try_recv_bounded(
&mut self,
max: usize,
) -> Result<ConsumerAccess<'_, T, PO, B>, TryRecvError>
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
Sourcepub fn try_recv_copies(
&mut self,
buffer: &mut [T],
) -> Result<usize, TryRecvError>where
T: Copy,
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