Jobsteal 
A work-stealing fork-join threadpool written in Rust.
This features low-level APIs to directly submit tasks to the pool,
along with a high-level parallel iteration API called Spliterator
,
which is very similar to Rust's Iterators.
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.
However, it's much easier to submit jobs in order like we did in the above example. Jobsteal's Spliterator
lets us feel like we're doing that,
while actually splitting the work optimally between threads!
Here's how:
use ;
Unwind Safety
A panic in one worker is intended to propagate to the main thread. However, the code hasn't been vetted for safety, so please try to avoid panicking in your jobs. There should probably be an UnwindSafe bound on job functions. This would require nightly, and UnwindSafe is also really cumbersome.