From c4531591e9396d86e57f32badcd8dd05edaafbfe Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 16 Sep 2022 09:03:46 +0200 Subject: [PATCH] async-http: Serve requests in parallel in threads Use async_std::task::spawn to launch a request in a thread. Now even synchronous sleep does not block other requests, as long as they don't exceed the thread pool capacity. --- async-http/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/async-http/src/main.rs b/async-http/src/main.rs index cf0b46d..c288408 100644 --- a/async-http/src/main.rs +++ b/async-http/src/main.rs @@ -15,7 +15,7 @@ async fn main() { listener.incoming().for_each_concurrent(/* limit */ None, |tcpstream| async move { let tcpstream = tcpstream.unwrap(); - handle_connection(tcpstream).await; + task::spawn(handle_connection(tcpstream)); }).await; } -- 2.39.2