pub fn spawn(self) -> Vec<JoinHandle<()>> {
        match self {
            Self::Single { mut worker } => {
                vec![std::thread::Builder::new()
                    .name(format!("{}_worker", THREAD_PREFIX))
                    .spawn(move || worker.run())
                    .unwrap()]
            }
            Self::Multi {
                mut storage,
                workers,
            } => {
                let mut threads = Vec::new();
                threads.push(
                    std::thread::Builder::new()
                        .name(format!("{}_storage", THREAD_PREFIX))
                        .spawn(move || storage.run())
                        .unwrap(),
                );
                for mut worker in workers {
                    let worker_thread = std::thread::Builder::new()
                        .name(format!("{}_worker{}", THREAD_PREFIX, threads.len()))
                        .spawn(move || worker.run())
                        .unwrap();
                    threads.push(worker_thread);
                }
                threads
            }
        }
    }
/// Converts the `Workers` into running threads.
Converts the `Workers` into running threads.
Converts the ` Workers ` into running threads .
pub fn spawn(self) -> Vec<JoinHandle<()>> {
        match self {
            Self::Single { mut worker } => {
                vec![std::thread::Builder::new()
                    .name(format!("{}_worker", THREAD_PREFIX))
                    .spawn(move || worker.run())
                    .unwrap()]
            }
            Self::Multi {
                mut storage,
                workers,
            } => {
                let mut threads = Vec::new();
                threads.push(
                    std::thread::Builder::new()
                        .name(format!("{}_storage", THREAD_PREFIX))
                        .spawn(move || storage.run())
                        .unwrap(),
                );
                for mut worker in workers {
                    let worker_thread = std::thread::Builder::new()
                        .name(format!("{}_worker{}", THREAD_PREFIX, threads.len()))
                        .spawn(move || worker.run())
                        .unwrap();
                    threads.push(worker_thread);
                }
                threads
            }
        }
    }
pub fn spawn ( self ) -> Vec < JoinHandle < ( ) > > { match self { Self :: Single { mut worker } => { vec ! [ std thread Builder new ( ) name ( format ( " " THREAD_PREFIX ) ) spawn ( move worker run ( ) ) unwrap ( ) ] } Self :: Multi { mut storage , workers , } => { let mut threads = Vec :: new ( ) ; threads . push ( std :: thread :: Builder :: new ( ) . name ( format ! ( " " THREAD_PREFIX ) ) . spawn ( move | | storage . run ( ) ) . unwrap ( ) , ) ; for mut worker in workers { let worker_thread = std :: thread :: Builder :: new ( ) . name ( format ! ( " " THREAD_PREFIX threads len ( ) ) ) . spawn ( move | | worker . run ( ) ) . unwrap ( ) ; threads . push ( worker_thread ) ; } threads } } }
Converts the `Workers` into running threads.
Converts the ` Workers ` into running threads .
self
self