Expand description
§foofighters
A lightweight, work-stealing thread pool.
§Example
Add this crate using cargo add foofighters:
use foofighters::pool::PoolBuilder;
let pool = PoolBuilder::new()
.set_worker_count(4)
.set_steal_amount(2)
.build();
let submission = pool.spawn(|| {
println!("Hello from a worker!");
});
submission.into_result().unwrap();§Lifecycle
Each worker thread runs this cycle:
- Execute all tasks in its local queue.
- Steal from the global queue if empty.
- Attempt to steal batches from other workers.
- Park when no work remains (and unpark when new tasks arrive).
- On shutdown, drain any remaining global tasks before exiting.
§Shutdown
When the Pool instance is dropped:
- Task submissions are automatically blocked.
- All worker threads are unparked.
- Each worker drains any remaining global tasks.
- The pool joins all threads before returning control.
§Tests
cargo testOr just check compilation without running them as running it will spawn threads:
cargo test --doc --no-run§License
MIT
Modules§
- pool
- Thread Pool Module