pub fn bounded_async<T>(size: usize) -> (AsyncSender<T>, AsyncReceiver<T>)Expand description
Creates a new async bounded channel with the requested buffer size, and
returns AsyncSender and AsyncReceiver of the channel for type T, you
can get access to sync API of Sender and Receiver with to_sync,
as_async or clone_sync based on your requirements, by calling them on
async sender or receiver.
ยงExamples
use tokio::{spawn as co};
let (s, r) = kanal_plus::bounded_async(0);
co(async move {
s.send("hello!").await?;
anyhow::Ok(())
});
assert_eq!(r.recv().await?, "hello!");
anyhow::Ok(())