blocking_async_mpsc

Function blocking_async_mpsc 

Source
pub fn blocking_async_mpsc<T, const P: usize, const NUM_SEGS_P2: usize>() -> (BlockingMpscSender<T, P, NUM_SEGS_P2>, AsyncMpscReceiver<T, P, NUM_SEGS_P2>)
Expand description

Creates a mixed MPSC queue with blocking senders and async receiver.

The blocking senders and async receiver share the same waker infrastructure, so they can wake each other efficiently. This is useful when you have blocking threads that need to send data to an async task.

§Example

let (sender, receiver) = blocking_async_mpsc();

// Senders (blocking threads)
for i in 0..4 {
    let sender = sender.clone();
    std::thread::spawn(move || {
        sender.send(i).unwrap();
    });
}

// Receiver (async task)
tokio::spawn(async move {
    while let Some(item) = receiver.next().await {
        println!("Got: {}", item);
    }
});