Skip to content

Commit

Permalink
Merge pull request #160 from gftea/patch-1
Browse files Browse the repository at this point in the history
Update 02_handling_connections_concurrently.md
  • Loading branch information
nrc authored Oct 5, 2024
2 parents 3c84923 + 13a9309 commit 38e7316
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/09_example/02_handling_connections_concurrently.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ As long as `handle_connection` does not block, a slow request will no longer pre
{{#include ../../examples/09_04_concurrent_tcp_server/src/main.rs:main_func}}
```
# Serving Requests in Parallel
Our example so far has largely presented concurrency (using async code)
as an alternative to parallelism (using threads).
Our example so far has largely presented cooperative multitasking concurrency (using async code)
as an alternative to preemptive multitasking (using threads).
However, async code and threads are not mutually exclusive.
In our example, `for_each_concurrent` processes each connection concurrently, but on the same thread.
The `async-std` crate allows us to spawn tasks onto separate threads as well.
Expand All @@ -49,6 +49,6 @@ Here's what that would look like:
```rust
{{#include ../../examples/09_05_final_tcp_server/src/main.rs:main_func}}
```
Now we are using both concurrency and parallelism to handle multiple requests at the same time!
Now we are using both cooperative multitasking concurrency and preemptive multitasking to handle multiple requests at the same time!
See the [section on multithreaded executors](../08_ecosystem/00_chapter.md#single-threading-vs-multithreading)
for more information.
for more information.

0 comments on commit 38e7316

Please sign in to comment.