pub fn new_named(
        name: String,
        core_size: usize,
        max_size: usize,
        keep_alive: Duration,
    ) -> Self {
        let (sender, receiver) = crossbeam_channel::unbounded();

        if max_size == 0 || max_size < core_size {
            panic!("max_size must be greater than 0 and greater or equal to the core pool size");
        } else if max_size > MAX_SIZE {
            panic!(
                "max_size may not exceed {}, the maximum value that can be stored within half the bits of usize ({} -> {} bits in this case)",
                MAX_SIZE,
                BITS,
                BITS / 2
            );
        }

        let worker_data = WorkerData {
            pool_name: name,
            worker_count_data: WorkerCountData::default(),
            worker_number: AtomicUsize::new(1),
            join_notify_condvar: Condvar::new(),
            join_notify_mutex: Mutex::new(()),
        };

        let channel_data = ChannelData { sender, receiver };

        Self {
            core_size,
            max_size,
            keep_alive,
            channel_data: Arc::new(channel_data),
            worker_data: Arc::new(worker_data),
        }
    }
/// Construct a new `ThreadPool` with the specified name, core pool size, max pool size
/// and keep_alive time for non-core threads. This function does not spawn any
/// threads.
///
/// `name` the name of the `ThreadPool` that will be used as prefix for each
/// thread.
///
/// `core_size` specifies the amount of threads to keep alive for as long as
/// the `ThreadPool` exists and its channel remains connected.
///
/// `max_size` specifies the maximum number of worker threads that may exist
/// at the same time.
///
/// `keep_alive` specifies the duration for which to keep non-core pool
/// worker threads alive while they do not receive any work.
///
/// # Panics
///
/// This function will panic if max_size is 0, 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.
Construct a new `ThreadPool` with the specified name, core pool size, max pool size
and keep_alive time for non-core threads. This function does not spawn any
threads.

`name` the name of the `ThreadPool` that will be used as prefix for each
thread.

`core_size` specifies the amount of threads to keep alive for as long as
the `ThreadPool` exists and its channel remains connected.

`max_size` specifies the maximum number of worker threads that may exist
at the same time.

`keep_alive` specifies the duration for which to keep non-core pool
worker threads alive while they do not receive any work.
Construct a new ` ThreadPool ` with the specified name core pool size max pool size and keep_alive time for non - core threads . This function does not spawn any threads . ` name ` the name of the ` ThreadPool ` that will be used as prefix for each thread . ` core_size ` specifies the amount of threads to keep alive for as long as the ` ThreadPool ` exists and its channel remains connected . ` max_size ` specifies the maximum number of worker threads that may exist at the same time . ` keep_alive ` specifies the duration for which to keep non - core pool worker threads alive while they do not receive any work .
pub fn new_named(
        name: String,
        core_size: usize,
        max_size: usize,
        keep_alive: Duration,
    ) -> Self {
        let (sender, receiver) = crossbeam_channel::unbounded();
        if max_size == 0 || max_size < core_size {
            panic!("max_size must be greater than 0 and greater or equal to the core pool size");
        } else if max_size > MAX_SIZE {
            panic!(
                "max_size may not exceed {}, the maximum value that can be stored within half the bits of usize ({} -> {} bits in this case)",
                MAX_SIZE,
                BITS,
                BITS / 2
            );
        }
        let worker_data = WorkerData {
            pool_name: name,
            worker_count_data: WorkerCountData::default(),
            worker_number: AtomicUsize::new(1),
            join_notify_condvar: Condvar::new(),
            join_notify_mutex: Mutex::new(()),
        };
        let channel_data = ChannelData { sender, receiver };
        Self {
            core_size,
            max_size,
            keep_alive,
            channel_data: Arc::new(channel_data),
            worker_data: Arc::new(worker_data),
        }
    }
pub fn new_named ( name : String , core_size : usize , max_size : usize , keep_alive : Duration , ) -> Self { let ( sender , receiver ) = crossbeam_channel :: unbounded ( ) ; if max_size == 0 || max_size < core_size { panic ! ( " " ) ; } else if max_size > MAX_SIZE { panic ! ( " " MAX_SIZE BITS BITS 2 ) ; } let worker_data = WorkerData { pool_name : name , worker_count_data : WorkerCountData :: default ( ) , worker_number : AtomicUsize :: new ( 1 ) , join_notify_condvar : Condvar :: new ( ) , join_notify_mutex : Mutex :: new ( ( ) ) , } ; let channel_data = ChannelData { sender , receiver } ; Self { core_size , max_size , keep_alive , channel_data : Arc :: new ( channel_data ) , worker_data : Arc :: new ( worker_data ) , } }
Construct a new `ThreadPool` with the specified name, core pool size, max pool size
and keep_alive time for non-core threads.
Construct a new ` ThreadPool ` with the specified name core pool size max pool size and keep_alive time for non - core threads .
name
String
core_size
usize
max_size
usize
keep_alive
Duration
name
String
core_size
usize
max_size
usize
keep_alive
Duration
panics
This function will panic if max_size is 0, 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.
This function will panic if max_size is 0 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 .