File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 33Spawning allows you to run a new asynchronous task in the background. This allows us to continue executing other code
44while it is running.
55
6- Say we have a webserver that wants to accept connections without blocking the main thread.
7- We can do this by using the ` async_std::task::spawn ` function to spawn a new task that runs
8- the connection handler . This function takes a future and returns a ` JoinHandle ` that can be
9- used to await the result of the spawned task .
6+ Say we have a web server that wants to accept connections without blocking the main thread.
7+ To achieve this, we can use the async_std::task::spawn function to create and run a new task that handles the
8+ connections . This function takes a future and returns a JoinHandle, which can be used to wait for the result of the
9+ task once it's completed .
1010
1111``` rust,edition2018
1212{{#include ../../examples/06_04_spawning/src/lib.rs:example}}
You can’t perform that action at this time.
0 commit comments