The team is back from vacation, and excited to share a new release of async-std! This release introduces the highly anticipated "async channels", which are an async version of crossbeam's channel::bounded
implementation -- also designed by @anon15139276.
I've been playing around with our channels for the past day or so, and they're surprisingly nice. An example of a channel with capacity(2):
// Create a new channel
let (s, r) = channel(2);
// Send items to the channel
s.send(1).await;
s.send(2).await;
// Receive items from the channel
assert_eq!(r.recv().await, Some(1));
assert_eq!(r.recv().await, Some(2));
If a channel is full, any further send()
calls will asynchronously wait to resolve until more capacity becomes available. This works well with future::timeout
to prevent channels from waiting indefinitely.
We've also added several new APIs, including Stream::timeout
and Future::delay
.
Also as of today there are 9 days left until async/await
goes stable, and we're hard at work prepping for our 1.0 release. We might try and squeeze in a final preview release before then though. But overall we're really excited for async/await
to finally be stable!