Struct threadpool::ThreadPool
[−]
[src]
pub struct ThreadPool { // some fields omitted }
A thread pool used to execute functions in parallel.
Spawns n
worker threads and replenishes the pool if any worker threads
panic.
Example
use threadpool::ThreadPool; use std::sync::mpsc::channel; let pool = ThreadPool::new(4); let (tx, rx) = channel(); for i in 0..8 { let tx = tx.clone(); pool.execute(move|| { tx.send(i).unwrap(); }); } assert_eq!(rx.iter().take(8).fold(0, |a, b| a + b), 28);