Clarify usage of runtimes in async book examples

In response to discussion on Zulip
[here](https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async-foundations/topic/meeting.202021.2E02.2E11)
This commit is contained in:
Lee Bernick 2021-02-16 20:20:52 -05:00
parent 4beff8d57e
commit c625717767
2 changed files with 7 additions and 1 deletions

View File

@ -4,6 +4,10 @@ Importantly, executors, tasks, reactors, combinators, and low-level I/O futures
are not yet provided in the standard library. In the meantime,
community-provided async ecosystems fill in these gaps.
The Async Foundations Team is interested in extending examples in the Async Book to cover multiple runtimes.
If you're interested in contributing to this project, please reach out to us on
[Zulip](https://rust-lang.zulipchat.com/#narrow/stream/201246-wg-async-foundations.2Fbook).
## Async Runtimes
Async runtimes are libraries used for executing async applications.
Runtimes usually bundle together a *reactor* with one or more *executors*.

View File

@ -36,9 +36,11 @@ We can't `await` or `poll` futures within synchronous code by itself.
We'll need an asynchronous runtime to handle scheduling and running futures to completion.
Please consult the [section on choosing a runtime](../08_ecosystem/00_chapter.md)
for more information on asynchronous runtimes, executors, and reactors.
Any of the runtimes listed will work for this project, but for these examples,
we've chosen to use the `async-std` crate.
## Adding an Async Runtime
Here, we'll use an executor from the `async-std` crate.
The following example will demonstrate refactoring synchronous code to use an async runtime; here, `async-std`.
The `#[async_std::main]` attribute from `async-std` allows us to write an asynchronous main function.
To use it, enable the `attributes` feature of `async-std` in `Cargo.toml`:
```toml