Function glommio::channels::local_channel::new_bounded[][src]

pub fn new_bounded<T>(size: usize) -> (LocalSender<T>, LocalReceiver<T>)
Expand description

Creates a new local_channel with capacity limited to the size argument

Examples

use futures_lite::StreamExt;
use glommio::{channels::local_channel, Local, LocalExecutor};

let ex = LocalExecutor::default();
ex.run(async move {
    let (sender, receiver) = local_channel::new_bounded(1);
    assert_eq!(sender.is_full(), false);
    sender.try_send(0);
    assert_eq!(sender.is_full(), true);
    receiver.stream().next().await.unwrap();
    assert_eq!(sender.is_full(), false);
});