mirror of https://github.com/rust-lang/async-book
Reworded a sentence
This commit is contained in:
parent
0f396afde7
commit
24861ba313
|
@ -3,10 +3,10 @@
|
|||
Spawning allows you to run a new asynchronous task in the background. This allows us to continue executing other code
|
||||
while it is running.
|
||||
|
||||
Say we have a webserver that wants to accept connections without blocking the main thread.
|
||||
We can do this by using the `async_std::task::spawn` function to spawn a new task that runs
|
||||
the connection handler. This function takes a future and returns a `JoinHandle` that can be
|
||||
used to await the result of the spawned task.
|
||||
Say we have a web server that wants to accept connections without blocking the main thread.
|
||||
To achieve this, we can use the async_std::task::spawn function to create and run a new task that handles the
|
||||
connections. This function takes a future and returns a JoinHandle, which can be used to wait for the result of the
|
||||
task once it's completed.
|
||||
|
||||
```rust,edition2018
|
||||
{{#include ../../examples/06_04_spawning/src/lib.rs:example}}
|
||||
|
|
Loading…
Reference in New Issue