/// Create working threads and start the event loop.
Create working threads and start the event loop.
Create working threads and start the event loop .
pub fn start(mgr: Arc<AsyncWorkerMgr>) -> Result<()> {
        // Hold the sender to barrier all working threads.
        let guard = mgr.sender.lock().unwrap();
        let threads = mgr.prefetch_config.threads_count;
        for num in 0..threads {
            let mgr2 = mgr.clone();
            let rx = mgr.receiver.clone();
            let res = thread::Builder::new()
                .name(format!("blob_async_thread_{}", num))
                .spawn(move || {
                    mgr2.grow_n(1);
                    mgr2.metrics
                        .prefetch_workers
                        .fetch_add(1, Ordering::Relaxed);
                    mgr2.run(rx);
                    mgr2.metrics
                        .prefetch_workers
                        .fetch_sub(1, Ordering::Relaxed);
                    mgr2.shrink_n(1);
                    info!("Prefetch thread exits.")
                });
            if let Err(e) = res {
                error!("Create prefetch worker failed, {:?}", e);
                drop(guard);
                mgr.stop();
                return Err(e);
            }
        }
        Ok(())
    }
pub fn start ( mgr : Arc < AsyncWorkerMgr > ) -> Result < ( ) > { // Hold the sender to barrier all working threads. let guard = mgr . sender . lock ( ) . unwrap ( ) ; let threads = mgr . prefetch_config . threads_count ; for num in 0 .. threads { let mgr2 = mgr . clone ( ) ; let rx = mgr . receiver . clone ( ) ; let res = thread :: Builder :: new ( ) . name ( format ! ( " " num ) ) . spawn ( move | | { mgr2 . grow_n ( 1 ) ; mgr2 . metrics . prefetch_workers . fetch_add ( 1 , Ordering :: Relaxed ) ; mgr2 . run ( rx ) ; mgr2 . metrics . prefetch_workers . fetch_sub ( 1 , Ordering :: Relaxed ) ; mgr2 . shrink_n ( 1 ) ; info ! ( " " ) } ) ; if let Err ( e ) = res { error ! ( " " e ) ; drop ( guard ) ; mgr . stop ( ) ; return Err ( e ) ; } } Ok ( ( ) ) }
Create working threads and start the event loop.
Create working threads and start the event loop .
mgr
Arc<AsyncWorkerMgr>