pub fn async_blocking_mpsc<T, const P: usize, const NUM_SEGS_P2: usize>() -> (AsyncMpscSender<T, P, NUM_SEGS_P2>, BlockingMpscReceiver<T, P, NUM_SEGS_P2>)Expand description
Creates a mixed MPSC queue with async senders and blocking receiver.
The async senders and blocking receiver share the same waker infrastructure, so they can wake each other efficiently. This is useful when you have async tasks that need to send data to a blocking thread.
§Example
ⓘ
let (sender, receiver) = async_blocking_mpsc();
// Senders (async tasks)
for i in 0..4 {
let sender = sender.clone();
tokio::spawn(async move {
sender.send(i).await.unwrap();
});
}
// Receiver (blocking thread)
std::thread::spawn(move || {
while let Ok(item) = receiver.recv() {
println!("Got: {}", item);
}
});