5 releases (3 breaking)
0.4.0 | Jan 16, 2021 |
---|---|
0.3.1 | Jan 15, 2021 |
0.3.0 | Jan 15, 2021 |
0.2.0 | Jan 14, 2021 |
0.1.0 | Jan 14, 2021 |
#12 in #spmc
10KB
171 lines
threaded
Minimalist Thread Pool in Rust
Glanceable source code for prototypes seeking brevity with transparency.
Stability
Experimental
Threaded is not fully covered nor benched let alone comparatively performance tested.
Branching Strategy
Usage
use threaded::ThreadPool;
// start thread pool with fixed capacity of 2 workers (single producer, multiple consumer; spmc)
let tp = ThreadPool::new(2);
tp.execute(|| println!("hello threaded!")); // 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(tp); // manually trigger drop and join threads
See docs.rs/threaded.
Credits
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".
License
Dependencies
~0.5–1MB
~17K SLoC