-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: okay, just introducing this is ridiculously hard 😅
- Loading branch information
1 parent
814920a
commit e3a2714
Showing
3 changed files
with
63 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,9 @@ multiple threads. While mainstream desktop and mobile operating systems have all | |
had threading for many years, many embedded operating systems used on | ||
microcontrollers do not. | ||
|
||
The async-await model provides a different, complementary set of tradeoffs. | ||
The async-await model provides a different, complementary set of tradeoffs. The | ||
|
||
<!-- TODO: the following paragraph is not where it needs to be structurally. --> | ||
|
||
In the async-await model, concurrent operations do not require their own | ||
threads. Instead, they can run on *tasks*. A task is a bit like a thread, but | ||
|
@@ -19,3 +21,29 @@ Erlang, and Swift, ship runtimes with the language. In Rust, there are many | |
different runtimes, because the things a runtime for a high-throughput web | ||
server should do are very different from the things a runtime for a | ||
microcontroller should do. | ||
|
||
<!-- TODO: connective tissue as it were. --> | ||
|
||
|
||
For the rest of this chapter, we are going to use the simple executor from the | ||
`futures` crate. | ||
|
||
<!-- TODO: the code samples will need to actually be turned into listings. --> | ||
|
||
``` | ||
cargo add [email protected] | ||
``` | ||
|
||
In Listing 16-01, we saw a simple example of multithreading. Let’s see a | ||
similarly simple example with `async` and `await`. | ||
|
||
```rust | ||
``` | ||
|
||
<span class="caption">Listing 17-1: Creating a new thread to print one thing | ||
while the main thread prints something else</span> | ||
|
||
So far, these look pretty similar. Both of them involve calling | ||
|
||
Where things start to look very different is when they want to trigger *further* | ||
concurrent behavior themselves. In the threaded model, |