foofighters
A lightweight, work-stealing thread pool.
Example
Add this crate using cargo add foofighters:
use PoolBuilder;
let pool = new
.set_worker_count
.set_steal_amount
.build;
let submission = pool.spawn;
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
Or just check compilation without running them as running it will spawn threads:
License
MIT