pub struct Receiver<T, const P: usize, const NUM_SEGS_P2: usize> { /* private fields */ }Implementations§
Source§impl<T, const P: usize, const NUM_SEGS_P2: usize> Receiver<T, P, NUM_SEGS_P2>
impl<T, const P: usize, const NUM_SEGS_P2: usize> Receiver<T, P, NUM_SEGS_P2>
pub fn next(&mut self) -> u64
Sourcepub fn close(&self) -> bool
pub fn close(&self) -> bool
Close the queue
After closing, no more items can be pushed. This method will block until all SPSC queues are empty. Wakes any waiting consumer.
Note: This waits for consumer to drain all items from all producer queues.
Sourcepub fn producer_count(&self) -> usize
pub fn producer_count(&self) -> usize
Get the number of registered producers
pub fn create_sender(&self) -> Result<Sender<T, P, NUM_SEGS_P2>, PushError<()>>
Sourcepub fn create_sender_with_config(
&self,
max_pooled_segments: usize,
) -> Result<Sender<T, P, NUM_SEGS_P2>, PushError<()>>
pub fn create_sender_with_config( &self, max_pooled_segments: usize, ) -> Result<Sender<T, P, NUM_SEGS_P2>, PushError<()>>
Create a new producer handle that bypasses all thread-local caching
This creates a direct, high-performance handle to a specific producer queue. The handle provides push-only access without any thread-local overhead, making it ideal for scenarios where you need maximum performance and want to maintain explicit control over producer instances.
Unlike get_producer_queue(), this method:
- Does not register with thread-local storage
- Does not use caching mechanisms
- Provides a standalone handle that can be stored and reused
- Offers maximum push performance
§Returns
Returns a ProducerHandle that can be used to push values, or PushError::Closed
if the MPSC queue is closed.
§Example
let mpsc = MpscBlocking::<i32, 64>::new();
// Create a direct producer handle
let producer = mpsc.create_producer_handle().unwrap();
// Use the handle for high-performance pushes
producer.push(42).unwrap();
producer.push_bulk(&[1, 2, 3]).unwrap();
```ignoreSourcepub fn try_pop(&mut self) -> Result<T, PopError>
pub fn try_pop(&mut self) -> Result<T, PopError>
Pop a value from the queue (non-blocking) using supplied Selector
Returns immediately with Empty if no items are available.
§Safety
This method may not be called concurrently from multiple threads.
pub fn try_pop_n(&mut self, batch: &mut [T]) -> usize
Sourcepub fn try_pop_with_id(&mut self) -> Result<(T, usize), PopError>
pub fn try_pop_with_id(&mut self) -> Result<(T, usize), PopError>
Attempts to pop a single value and returns the item along with the producer id.