/// Start a thread pool
/// This function spawn `min_workers` threads.
Start a thread pool
This function spawn `min_workers` threads.
Start a thread pool This function spawn ` min_workers ` threads .
pub fn start(config: ThreadPoolConfig, shared: Shared) -> Self {
        let state = State::new(config);
        let (sender, receiver) = if let Some(queue_size) = config.queue_size {
            flume::bounded(queue_size)
        } else {
            flume::unbounded()
        };
        for _ in 0..config.min_workers.get() {
            let worker = Worker::new(
                config.keep_alive,
                receiver.clone(),
                sender.clone(),
                shared.clone(),
                state.clone(),
            );
            std::thread::spawn(move || worker.run());
        }
        ThreadPool { sender }
    }
pub fn start ( config : ThreadPoolConfig , shared : Shared ) -> Self { let state = State :: new ( config ) ; let ( sender , receiver ) = if let Some ( queue_size ) = config . queue_size { flume :: bounded ( queue_size ) } else { flume :: unbounded ( ) } ; for _ in 0 .. config . min_workers . get ( ) { let worker = Worker :: new ( config . keep_alive , receiver . clone ( ) , sender . clone ( ) , shared . clone ( ) , state . clone ( ) , ) ; std :: thread :: spawn ( move | | worker . run ( ) ) ; } ThreadPool { sender } }
Start a thread pool
This function spawn `min_workers` threads.
Start a thread pool This function spawn ` min_workers ` threads .
config
ThreadPoolConfig
shared
Shared