Skip to content

Commit a4cccb1

Browse files
committed
link and more apostrophes
1 parent 310cda6 commit a4cccb1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

docs/src/concepts/tasks.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Now that we know what Futures are, we now want to run them!
44

5-
In `async-std`, the `tasks` (TODO: link) module is responsible for this. The simplest way is using the `block_on` function:
5+
In `async-std`, the [`tasks`][tasks] module is responsible for this. The simplest way is using the `block_on` function:
66

77
```rust
88
use async_std::fs::File;
@@ -29,7 +29,7 @@ fn main() {
2929
}
3030
```
3131

32-
This asks the runtime baked into `async_std` to execute the code that reads a file. Lets go one by one, though, inside to outside.
32+
This asks the runtime baked into `async_std` to execute the code that reads a file. Let's go one by one, though, inside to outside.
3333

3434
```rust
3535
async {
@@ -43,28 +43,28 @@ async {
4343

4444
This is an `async` *block*. Async blocks are necessary to call `async` functions, and will instruct the compiler to include all the relevant instructions to do so. In Rust, all blocks return a value and `async` blocks happen to return a value of the kind `Future`.
4545

46-
But lets get to the interesting part:
46+
But let's get to the interesting part:
4747

4848
```rust
4949

5050
task::spawn(async { })
5151

5252
```
5353

54-
`spawn` takes a Future and starts running it on a `Task`. It returns a `JoinHandle`. Futures in Rust are sometimes called *cold* Futures. You need something that starts running them. To run a Future, there may be some additional bookkeeping required, e.g. if it's running or finished, where it is being placed in memory and what the current state is. This bookkeeping part is abstracted away in a `Task`. A `Task` is similar to a `Thread`, with some minor differences: it will be scheduled by the program instead of the operating system kernel and if it encounters a point where it needs to wait, the program itself responsible for waking it up again. Well talk a little bit about that later. An `async_std` task can also has a name and an ID, just like a thread.
54+
`spawn` takes a Future and starts running it on a `Task`. It returns a `JoinHandle`. Futures in Rust are sometimes called *cold* Futures. You need something that starts running them. To run a Future, there may be some additional bookkeeping required, e.g. if it's running or finished, where it is being placed in memory and what the current state is. This bookkeeping part is abstracted away in a `Task`. A `Task` is similar to a `Thread`, with some minor differences: it will be scheduled by the program instead of the operating system kernel and if it encounters a point where it needs to wait, the program itself responsible for waking it up again. We'll talk a little bit about that later. An `async_std` task can also has a name and an ID, just like a thread.
5555

5656
For now, it is enough to know that once you `spawn`ed a task, it will continue running in the background. The `JoinHandle` in itself is a future that will finish once the `Task` ran to conclusion. Much like with `threads` and the `join` function, we can now call `block_on` on the handle to *block* the program (or the calling thread, to be specific) to wait for it to finish.
5757

5858
## Tasks in `async_std`
5959

60-
Tasks in `async_std` are one of the core abstractions. Much like Rusts `thread`s, they provide some practical functionality over the raw concept. `Tasks` have a relationship to the runtime, but they are in themselves separate. `async_std` tasks have a number of desirable properties:
60+
Tasks in `async_std` are one of the core abstractions. Much like Rust's `thread`s, they provide some practical functionality over the raw concept. `Tasks` have a relationship to the runtime, but they are in themselves separate. `async_std` tasks have a number of desirable properties:
6161

6262
- They are allocated in one single allocation
6363
- All tasks have a *backchannel*, which allows them to propagate results and errors to the spawning task through the `JoinHandle`
6464
- The carry desirable metadata for debugging
6565
- They support task local storage
6666

67-
`async_std`s task api handles setup and teardown of a backing runtime for you and doesnt rely on a runtime being started.
67+
`async_std`s task api handles setup and teardown of a backing runtime for you and doesn't rely on a runtime being started.
6868

6969
## Blocking
7070

@@ -126,4 +126,6 @@ That might seem odd at first, but the other option would be to silently ignore p
126126

127127
`async_std` comes with a useful `Task` type that works with an API similar to `std::thread`. It covers error and panic behaviour in a structured and defined way.
128128

129-
Tasks are separate concurrent units and sometimes they need to communicate. That’s where `Stream`s come in.
129+
Tasks are separate concurrent units and sometimes they need to communicate. That's where `Stream`s come in.
130+
131+
[tasks]: https://docs.rs/async-std/latest/async_std/task/index.html

0 commit comments

Comments
 (0)