mirror of https://github.com/rust-lang/async-book
Merge pull request #126 from lbernick/runtimes
Clarify usage of runtimes in async book examples
This commit is contained in:
commit
2b0aad627c
|
@ -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*.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue