A flexible thread pool providing scoped and static threads.
Example of simple use (applying a transformation to every item in an array):
extern crate scoped_pool; use Pool; let pool = new; let mut buf = ; pool.scoped; assert_eq!;
Besides the core API used above (
Pool::scoped) this crate also
provides many extremely useful convenience functions for complex code using
Also includes the raw
WaitGroup type, which can be used to implement similar
"wait for a group of actions to complete" logic, and is used in
See the generated documentation (linked above) for details.
Unlike many other scoped threadpool crates, this crate is designed to be
Scope are both
Send + Sync,
and both have many useful conveniences such as:
Pool::spawn for spawning
Pool::expand for expanding the number of threads in the pool.
Pool::shutdown for shutting down the pool.
Scope::zoom for externalizing
Scope management and
allowing fine-grained control over when jobs are scheduled and waited on.
Nearly all methods on both types require only an immutable borrow, and thus are safe to use concurrently without external synchronization.
In addition, the internal design of this crate is carefully constructed so that
all unsafety is encapsulated in the
Scope type, which effectively just adds
lifetime scoping to the
WaitGroup type for jobs scheduled on a
Use the crates.io repository; add this to your
with the rest of your dependencies:
 = "0.1"
Jonathan Reem is the primary author and maintainer of scoped-pool.