/// Create a new instance of `AsyncWorkerMgr`.
Create a new instance of `AsyncWorkerMgr`.
Create a new instance of ` AsyncWorkerMgr ` .
pub fn new(
        metrics: Arc<BlobcacheMetrics>,
        prefetch_config: Arc<AsyncPrefetchConfig>,
    ) -> Result<Self> {
        // If the given value is less than maximum blob chunk size, it exceeds burst size of the
        // limiter ending up with throttling all throughput, so ensure bandwidth is bigger than
        // the maximum chunk size.
        let tweaked_bw_limit = if prefetch_config.bandwidth_rate != 0 {
            std::cmp::max(RAFS_MAX_CHUNK_SIZE as u32, prefetch_config.bandwidth_rate)
        } else {
            0
        };
        let prefetch_limiter = NonZeroU32::new(tweaked_bw_limit).map(|v| {
            info!("Prefetch bandwidth will be limited at {}Bytes/S", v);
            Arc::new(RateLimiter::direct(Quota::per_second(v)))
        });
        let (sender, receiver) = channel::<AsyncRequestMessage>();
        Ok(AsyncWorkerMgr {
            metrics,
            receiver,
            sender: Mutex::new(sender),
            workers: AtomicU32::new(0),
            busy_workers: AtomicU32::new(0),
            pings: AtomicU32::new(0),
            exiting: AtomicBool::new(false),
            prefetch_config,
            prefetch_limiter,
        })
    }
pub fn new ( metrics : Arc < BlobcacheMetrics > , prefetch_config : Arc < AsyncPrefetchConfig > , ) -> Result < Self > { // If the given value is less than maximum blob chunk size, it exceeds burst size of the // limiter ending up with throttling all throughput, so ensure bandwidth is bigger than // the maximum chunk size. let tweaked_bw_limit = if prefetch_config . bandwidth_rate != 0 { std :: cmp :: max ( RAFS_MAX_CHUNK_SIZE as u32 , prefetch_config . bandwidth_rate ) } else { 0 } ; let prefetch_limiter = NonZeroU32 :: new ( tweaked_bw_limit ) . map ( | v | { info ! ( " " v ) ; Arc :: new ( RateLimiter :: direct ( Quota :: per_second ( v ) ) ) } ) ; let ( sender , receiver ) = channel :: < AsyncRequestMessage > ( ) ; Ok ( AsyncWorkerMgr { metrics , receiver , sender : Mutex :: new ( sender ) , workers : AtomicU32 :: new ( 0 ) , busy_workers : AtomicU32 :: new ( 0 ) , pings : AtomicU32 :: new ( 0 ) , exiting : AtomicBool :: new ( false ) , prefetch_config , prefetch_limiter , } ) }
Create a new instance of `AsyncWorkerMgr`.
Create a new instance of ` AsyncWorkerMgr ` .
metrics
Arc<BlobcacheMetrics>
prefetch_config
Arc<AsyncPrefetchConfig>