fn clone(&self) -> Pool<T> {
        Pool {
            jobs: Arc::clone(&self.jobs),
            shared_data: Arc::clone(&self.shared_data),
        }
    }
/// Cloning a pool will create a new handle to the pool.
/// The behavior is similar to [Arc](https://doc.rust-lang.org/stable/std/sync/struct.Arc.html).
///
/// We could for example submit jobs from multiple threads concurrently.
///
/// ```
/// # extern crate workerpool;
/// use workerpool::Pool;
/// use workerpool::thunk::{Thunk, ThunkWorker};
/// use std::thread;
/// use std::sync::mpsc::channel;
///
/// # fn main() {
/// let pool: Pool<ThunkWorker<()>> = Pool::with_name("clone example".into(), 2);
///
/// let results = (0..2)
///     .map(|i| {
///         let pool = pool.clone();
///         thread::spawn(move || {
///             let (tx, rx) = channel();
///             for i in 1..12 {
///                 let tx = tx.clone();
///                 pool.execute(Thunk::of(move || {
///                     tx.send(i).expect("channel will be waiting");
///                 }));
///             }
///             drop(tx);
///             if i == 0 {
///                 rx.iter().fold(0, |accumulator, element| accumulator + element)
///             } else {
///                 rx.iter().fold(1, |accumulator, element| accumulator * element)
///             }
///         })
///     })
///     .map(|join_handle| join_handle.join().expect("collect results from threads"))
///     .collect::<Vec<usize>>();
///
/// assert_eq!(vec![66, 39916800], results);
/// # }
/// ```
Cloning a pool will create a new handle to the pool.
The behavior is similar to [Arc].

We could for example submit jobs from multiple threads concurrently.


Cloning a pool will create a new handle to the pool . The behavior is similar to [ Arc ] . We could for example submit jobs from multiple threads concurrently .
fn clone(&self) -> Pool<T> {
        Pool {
            jobs: Arc::clone(&self.jobs),
            shared_data: Arc::clone(&self.shared_data),
        }
    }
fn clone ( & self ) -> Pool < T > { Pool { jobs : Arc :: clone ( & self . jobs ) , shared_data : Arc :: clone ( & self . shared_data ) , } }
Cloning a pool will create a new handle to the pool.
Cloning a pool will create a new handle to the pool .
&self
&self
extern crate workerpool;
use workerpool::Pool;
use workerpool::thunk::{Thunk, ThunkWorker};
use std::thread;
use std::sync::mpsc::channel.
use workerpool :: Pool ; use workerpool :: thunk :: { Thunk ThunkWorker } ; use std :: thread ; use std :: sync :: mpsc :: channel .
fn main() {
let pool: Pool> = Pool::with_name("clone example".into(), 2).

let results = (0..2)
.map(|i| {
let pool = pool.clone();
thread::spawn(move || {
let (tx, rx) = channel();
for i in 1..12 {
let tx = tx.clone();
pool.execute(Thunk::of(move || {
tx.send(i).expect("channel will be waiting");
}));
}
drop(tx);
if i == 0 {
rx.iter().fold(0, |accumulator, element| accumulator + element)
} else {
rx.iter().fold(1, |accumulator, element| accumulator * element)
}
})
})
.map(|join_handle| join_handle.join().expect("collect results from threads"))
.collect::>().


let pool : Pool > = Pool :: with_name ( " clone example " . into () 2 ) . let results = ( 0 .. 2 ) . map ( |i| { let pool = pool . clone () ; thread :: spawn ( move || { let ( tx rx ) = channel () ; for i in 1 .. 12 { let tx = tx . clone () ; pool . execute ( Thunk :: of ( move || { tx . send ( i ) . expect ( " channel will be waiting " ) ; } )) ; } drop ( tx ) ; if i == 0 { rx . iter () . fold ( 0 |accumulator element| accumulator + element ) } else { rx . iter () . fold ( 1 |accumulator element| accumulator * element ) } } ) } ) . map ( |join_handle| join_handle . join () . expect ( " collect results from threads " )) . collect :: > () .
}
None