Minimalist Thread Pool in Rust
Glanceable source code for prototypes seeking brevity with transparency.
Threaded is not fully covered nor benched let alone comparatively performance tested.
use ThreadPool; // start thread pool with fixed capacity of 2 workers (single producer, multiple consumer; spmc) let tp = new; tp.execute; // execute function in pool let _num_workers = tp.capacity; // get capacity of pool // once tp goes out of scope, drop is called // drop joins worker threads subsequently blocking main thread until workers finish drop; // manually trigger drop and join threads
The Rust Programming Language Book details integral features needed to begin writing useful programs while adhering to community guidelines. Threaded was based directly off the book's final project "Building a Multithreaded Web Server".