pub fn new(size: usize) -> ThreadPool {
        assert!(size > 0);
        let mut threads = Vec::with_capacity(size);
        let (sender, recevier) = mpsc::channel();
        let recevier = Arc::new(Mutex::new(recevier));

        for i in 0..size {
            threads.push(worker::Worker::new(i, Arc::clone(&recevier)));
        }
        ThreadPool { threads, sender }
    }
/// Create a new ThreadPool
///
/// The size is the number of threads in the pool.
///
/// # Panics
///
/// The `new` function will panic if the size is zero
Create a new ThreadPool
The size is the number of threads in the pool.
Create a new ThreadPool The size is the number of threads in the pool .
pub fn new(size: usize) -> ThreadPool {
        assert!(size > 0);
        let mut threads = Vec::with_capacity(size);
        let (sender, recevier) = mpsc::channel();
        let recevier = Arc::new(Mutex::new(recevier));
        for i in 0..size {
            threads.push(worker::Worker::new(i, Arc::clone(&recevier)));
        }
        ThreadPool { threads, sender }
    }
pub fn new ( size : usize ) -> ThreadPool { assert ! ( size 0 ) ; let mut threads = Vec :: with_capacity ( size ) ; let ( sender , recevier ) = mpsc :: channel ( ) ; let recevier = Arc :: new ( Mutex :: new ( recevier ) ) ; for i in 0 .. size { threads . push ( worker :: Worker :: new ( i , Arc :: clone ( & recevier ) ) ) ; } ThreadPool { threads , sender } }
Create a new ThreadPool
The size is the number of threads in the pool.
Create a new ThreadPool The size is the number of threads in the pool .
size
usize
size
usize
panics
The `new` function will panic if the size is zero
The ` new ` function will panic if the size is zero