foofighters

Crates.iofoofighters
lib.rsfoofighters
version0.1.0
created_at2025-10-31 15:08:11.789467+00
updated_at2025-10-31 15:08:11.789467+00
descriptionA lightweight, work-stealing thread pool.
homepagehttps://github.com/lovelindhoni/foofighters
repositoryhttps://github.com/lovelindhoni/foofighters
max_upload_size
id1910172
size22,657
Lovelin (lovelindhoni)

documentation

https://github.com/lovelindhoni/foofighters

README

foofighters

A lightweight, work-stealing thread pool.

Crates.io Docs.rs

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:

  1. Execute all tasks in its local queue.
  2. Steal from the global queue if empty.
  3. Attempt to steal batches from other workers.
  4. Park when no work remains (and unpark when new tasks arrive).
  5. 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 test

Or just check compilation without running them as running it will spawn threads:

cargo test --doc --no-run

License

MIT

Commit count: 0

cargo fmt