mirror of
https://github.com/guilhermewerner/mini-redis
synced 2025-06-16 15:05:39 +00:00
Add Concurrency to Server
This commit is contained in:
@ -9,7 +9,12 @@ async fn main() {
|
|||||||
loop {
|
loop {
|
||||||
// The second item contains the IP and port of the new connection.
|
// The second item contains the IP and port of the new connection.
|
||||||
let (socket, _) = listener.accept().await.unwrap();
|
let (socket, _) = listener.accept().await.unwrap();
|
||||||
|
|
||||||
|
// A new task is spawned for each inbound socket. The socket is
|
||||||
|
// moved to the new task and processed there.
|
||||||
|
tokio::spawn(async move {
|
||||||
process(socket).await;
|
process(socket).await;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user