pub fn build(self) -> ThreadPool {
        use std::cmp::{max, min};

        let core_size = self.core_size.unwrap_or_else(|| {
            let num_cpus = num_cpus::get();
            if let Some(max_size) = self.max_size {
                min(MAX_SIZE, min(num_cpus, max_size))
            } else {
                min(MAX_SIZE, num_cpus)
            }
        });
        // handle potential overflow: try using twice the core_size or return core_size
        let max_size = self
            .max_size
            .unwrap_or_else(|| min(MAX_SIZE, max(core_size, core_size * 2)));
        let keep_alive = self.keep_alive.unwrap_or_else(|| Duration::from_secs(60));

        if let Some(name) = self.name {
            ThreadPool::new_named(name, core_size, max_size, keep_alive)
        } else {
            ThreadPool::new(core_size, max_size, keep_alive)
        }
    }
/// Build the `ThreadPool` using the parameters previously supplied to this `Builder` using the number of CPUs as
/// default core size if none provided, twice the core size as max size if none provided, 60 seconds keep_alive
/// if none provided and the default naming (rusty_pool_{pool_number}) if none provided.
/// This function calls [`ThreadPool::new`](struct.ThreadPool.html#method.new) or
/// [`ThreadPool::new_named`](struct.ThreadPool.html#method.new_named) depending on whether a name was provided.
///
/// # Panics
///
/// Building might panic if the `max_size` is 0 or lower than `core_size` or exceeds half
/// the size of usize. This restriction exists because two counters (total workers and
/// idle counters) are stored within one AtomicUsize.
Build the `ThreadPool` using the parameters previously supplied to this `Builder` using the number of CPUs as
default core size if none provided, twice the core size as max size if none provided, 60 seconds keep_alive
if none provided and the default naming (rusty_pool_{pool_number}) if none provided.
Build the ` ThreadPool ` using the parameters previously supplied to this ` Builder ` using the number of CPUs as default core size if none provided twice the core size as max size if none provided 60 seconds keep_alive if none provided and the default naming ( rusty_pool_ { pool_number } ) if none provided .
pub fn build(self) -> ThreadPool {
        use std::cmp::{max, min};
        let core_size = self.core_size.unwrap_or_else(|| {
            let num_cpus = num_cpus::get();
            if let Some(max_size) = self.max_size {
                min(MAX_SIZE, min(num_cpus, max_size))
            } else {
                min(MAX_SIZE, num_cpus)
            }
        });
        // handle potential overflow: try using twice the core_size or return core_size
        let max_size = self
            .max_size
            .unwrap_or_else(|| min(MAX_SIZE, max(core_size, core_size * 2)));
        let keep_alive = self.keep_alive.unwrap_or_else(|| Duration::from_secs(60));
        if let Some(name) = self.name {
            ThreadPool::new_named(name, core_size, max_size, keep_alive)
        } else {
            ThreadPool::new(core_size, max_size, keep_alive)
        }
    }
pub fn build ( self ) -> ThreadPool { use std :: cmp :: { max , min } ; let core_size = self . core_size . unwrap_or_else ( | | { let num_cpus = num_cpus :: get ( ) ; if let Some ( max_size ) = self . max_size { min ( MAX_SIZE , min ( num_cpus , max_size ) ) } else { min ( MAX_SIZE , num_cpus ) } } ) ; // handle potential overflow: try using twice the core_size or return core_size let max_size = self . max_size . unwrap_or_else ( | | min ( MAX_SIZE , max ( core_size , core_size * 2 ) ) ) ; let keep_alive = self . keep_alive . unwrap_or_else ( | | Duration :: from_secs ( 60 ) ) ; if let Some ( name ) = self . name { ThreadPool :: new_named ( name , core_size , max_size , keep_alive ) } else { ThreadPool :: new ( core_size , max_size , keep_alive ) } }
Build the `ThreadPool` using the parameters previously supplied to this `Builder` using the number of CPUs as
default core size if none provided, twice the core size as max size if none provided, 60 seconds keep_alive
if none provided and the default naming (rusty_pool_{pool_number}) if none provided.
Build the ` ThreadPool ` using the parameters previously supplied to this ` Builder ` using the number of CPUs as default core size if none provided twice the core size as max size if none provided 60 seconds keep_alive if none provided and the default naming ( rusty_pool_ { pool_number } ) if none provided .
self
self
panics
Building might panic if the `max_size` is 0 or lower than `core_size` or exceeds half
the size of usize. This restriction exists because two counters (total workers and
idle counters) are stored within one AtomicUsize.
Building might panic if the ` max_size ` is 0 or lower than ` core_size ` or exceeds half the size of usize . This restriction exists because two counters ( total workers and idle counters ) are stored within one AtomicUsize .