2 ms·
Interestingly, a multi-threaded web server is the final chapter of "The Rust Programming Language" (full code is at the end of https://doc.rust-lang.org/stable/
by steveklabnik 7y ago
Interestingly, a multi-threaded web server is the final chapter of "The Rust Programming Language" (full code is at the end of https://doc.rust-lang.org/stable/book/ch20-03-graceful-shutdown-and-cleanup.html https://doc.rust-lang.org/stable/book/ch20-03-graceful-shutd... )
It ends up being pretty short, though we also build a threadpool by hand. If you used a package, it'd be even smaller. (I like scoped_threadpool myself) (And the FnBox stuff will go away once I write an update for it, it's no longer needed.)
It does the same: grab a connection, spawn the thread. There's virtually no borrowing.