A thread-pooling server

Let's adapt our overwhelmed TCP server to use a fixed number of threads. We'll start a new project whose Cargo.toml looks like:

[package]
name = "fixed_threads_server"
version = "0.1.0"
authors = ["Brian L. Troutwine <brian@troutwine.us>"]

[dependencies]
clap = "2.31"
slog = "2.2"
slog-term = "2.4"
slog-async = "2.3"
threadpool = "1.7"

[[bin]]
name = "server"

[[bin]]
name = "client"

This is almost exactly the same as the unbounded thread project, save that the name has been changed from overwhelmed_tpc_server to fixed_threads_tcp_server and we've added a new dependencythreadpool. There are a few different, stable thread-pool libraries available in crates, each with a slightly different feature set or focus. The workerpool ...

Get Hands-On Concurrency with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.