mirror of
https://github.com/guilhermewerner/mini-redis
synced 2025-06-15 14:35:13 +00:00
Add Concurrency to Server
This commit is contained in:
@ -9,7 +9,12 @@ async fn main() {
|
||||
loop {
|
||||
// The second item contains the IP and port of the new connection.
|
||||
let (socket, _) = listener.accept().await.unwrap();
|
||||
process(socket).await;
|
||||
|
||||
// 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user