Crates.io | threaded |
lib.rs | threaded |
version | 0.4.0 |
source | src |
created_at | 2021-01-14 14:26:31.173004 |
updated_at | 2021-01-16 22:38:01.330943 |
description | Minimalist Thread Pool |
homepage | https://crates.io/crates/threaded |
repository | https://github.com/gregl83/threaded |
max_upload_size | |
id | 341932 |
size | 11,738 |
Minimalist Thread Pool in Rust
Glanceable source code for prototypes seeking brevity with transparency.
Experimental
Threaded is not fully covered nor benched let alone comparatively performance tested.
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.
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".