Jobsteal
A work-stealing fork-join threadpool written in Rust.
See the Documentation
Examples
This is a basic example to show a simple way to use the job pool.
use make_pool;
Here's a more useful example where we split up a vector into chunks and submit a job for every part. This makes use of the scoping feature.
use make_pool;
The spawner passed to the "scope" closure can be used to create more scopes -- as nested as you'd like.
Each job function can have a spawner passed to it as well by spawning jobs with Spawner::recurse
, so you can very easily split tasks recursively.
Recursive work-splitting typically leads to much better work distribution between worker threads.
Recover Safety
A panic in one worker is intended to propagate to the main thread eventually. However, the code hasn't been vetted for safety, so please try to avoid panicking in your jobs. There should probably be a RecoverSafe bound on job functions. This would require nightly, and RecoverSafe is also really cumbersome.