]>
git.proxmox.com Git - rustc.git/blob - src/doc/book/listings/ch20-web-server/listing-20-14/src/lib.rs
4 pub struct ThreadPool
{
5 threads
: Vec
<thread
::JoinHandle
<()>>,
11 /// Create a new ThreadPool.
13 /// The size is the number of threads in the pool.
17 /// The `new` function will panic if the size is zero.
19 pub fn new(size
: usize) -> ThreadPool
{
22 let mut threads
= Vec
::with_capacity(size
);
25 // create some threads and store them in the vector
28 ThreadPool { threads }
33 pub fn execute
<F
>(&self, f
: F
)
35 F
: FnOnce() + Send
+ '
static,