

async-std 0.9.12: async/.await is ready
source link: https://async.rs/blog/async-std-0-9-12-async-await-is-ready/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Today marks the release of Rust 1.39, with a finally ready async/.await
feature.
In our announcement blog post
, we communicated our intent to ship async-std
on the release day of this feature. We will miss this deadline by a few days, but give you a short roadmap here.
The delay is caused by the futures-rs
library, which we depend on, making their final release yesterday. We highly respect futures-rs
timeline, the time was well spend in release polish and we congratulate the team to their release! Still, this means that we will release async-std
a little later, to also give ourselves time for quality control and release polish. The current release date is Monday, November 11th
.
Today, we will release async-std
0.9.12
, a final point release for you to play around with the new async/.await
feature.
The best way to try futures-rs
async-std
is an easy to use, well-documented library that provides an interface very close to Rust’s standard library. It provides implementations of all important I/O types like TcpListener
, File
and others. It is compatible with all libraries that are using futures-rs
as their library interface.
In practice, that means that async_std::stream::Stream
can be used anywhere a futures::stream::Stream
is expected and all I/O types can be used anywhere AsyncRead
and AsyncWrite
are expected.
async-std
provides a book to learn the finer details and background
, which we will keep continuously expanding. It supplements the official async book
.
On top of that, async-std
make spawning tasks as easy as possible. For example, async-std
unifies blocking and non-blocking tasks in the async_std::task
module under an interface similar to std::thread::JoinHandle
.
use async_std::task; use std::thread; use std::time::Duration; fn main() { task::block_on(async { let tasks: Vec<task::JoinHandle<()>> = vec![]; let task = task::spawn(move { task::sleep(Duration::from_millis(1000)).await; }); let blocking = task::spawn_blocking(move { thread::sleep(Duration::from_millis(1000)); }); tasks.push(task); tasks.push(blocking); for task in tasks { task.await } }); }
The JoinHandle
makes it easy to spawn tasks and retrieve their results in a uniform fashion. Also, every spawned task is stored within a single allocation, making this process is quick and efficient.
See the
task
module for more details.
Current Status
async-std
has been mainly focused on stabilising and trying out its interface over the last couple of months. We have used the time to gather confidence in out concept of the port of Rust’s std
to the async world.
A lot of time has been spent in proper integration into the current futures library, so that you can use both the direct async-std
interface and the futures-rs
common traits to interact with async-std
.
We have moved a number of newer features under the feature flag unstable
, which acts as a stability gate similar to the #![feature(…)]
attribute used in nightly versions of Rust’s standard library. One of those features is a very fast implementation of MPMC (Multiple Sender Multiple Receiver) channels
, which will cover most usecases people might have. We’re still taking feedback on their interface.
We feel confident about the release and the stability promised it brings. The 1.0
version covers all important parts to build an async system.
Meet us at RustFest!
Finally, meet us all at the async/.await special edition of RustFest
! We’ll be around the whole weekend, including the impl Days
! We’re happy to assist you in making your library run on top of async-std
or help you on your first contribution to async-std
or related libraries.
Recommend
-
126
在很长一段时间里面,FE们不得不依靠回调来处理异步代码。使用回调的结果是,代码变得很纠结,不便于理解与维护,值得庆幸的是Promise带来了.then(),让代码变得井然有序,便于管理。于是我们大量使用,代替了原来的回调方式。但是不存在一种方法可以让当前的执行流...
-
76
ASP.NET 谨用 async/await
-
75
C# 5.0 引入 async/await 关键字,旨在简化异步编程模型,抛去语法糖就是 Net4.0 的 Task + 状态机。其实在处理异步编程使用 Task 还是挺简单的,不过既然推出了新的语法糖,难免会尝试一下,然而在使用中却没想象中那么单纯。以下针对ASP.NET 应用程序实际使用过...
-
81
So I finally hopped on the boat with usa...
-
44
I’m really excited to announce the culmination of much of our work over the last four months: a pair of RFCs for supporting async & await notation in Rust. This will be very impactful for Rust in the network services...
-
36
C++11中提供了异步线程接口std::async,std::async是异步编程的高级封装,相对于直接使用std::thread,std::async的优势在于: 1、std::async会自动创建线程去调用线程函数,相对于低层次的std::thread,使用起来非常方便;
-
3
C++ std::async with a concurrency limit (via semaphores) Published: 09-01-2021 | Last update: 10-01-2021 | Author: Remy van Elst | Text only version...
-
9
C++ 的标准异步库 std::async 作者: 张志强 ,...
-
7
[转] 深入浅出 C++ 11 std::async [转] 深入浅出 C++ 11 std::async Kehan Xue...
-
8
What happens if you co_await a std::future, and why is it a bad idea?
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK