pub fn send(&self, msg: AsyncRequestMessage) -> Result<()> {
        match &msg {
            AsyncRequestMessage::FsPrefetch(_, _, req) => {
                if let Some(ref limiter) = self.prefetch_limiter {
                    let size = std::cmp::min(req.blob_size, u32::MAX as u64) as u32;
                    let cells = match NonZeroU32::new(size) {
                        Some(v) => v,
                        None => return Ok(()),
                    };
                    if let Err(e) = limiter
                        .check_n(cells)
                        .or_else(|_| block_on(limiter.until_n_ready(cells)))
                    {
                        // `InsufficientCapacity` is the only possible error
                        // Have to give up to avoid dead-loop
                        error!("{}: give up rate-limiting", e);
                    }
                }
            }
            AsyncRequestMessage::BlobPrefetch(_, _, _, size) => {
                if let Some(ref limiter) = self.prefetch_limiter {
                    let size = std::cmp::min(*size, u32::MAX as u64) as u32;
                    let cells = match NonZeroU32::new(size) {
                        Some(v) => v,
                        None => return Ok(()),
                    };
                    if let Err(e) = limiter
                        .check_n(cells)
                        .or_else(|_| block_on(limiter.until_n_ready(cells)))
                    {
                        // `InsufficientCapacity` is the only possible error
                        // Have to give up to avoid dead-loop
                        error!("{}: give up rate-limiting", e);
                    }
                }
            }
            _ => {}
        }

        let mut sender = self.sender.lock().unwrap();
        sender.send(msg).map_err(|e| {
            warn!("no more receiver for channel, {}", e);
            eio!()
        })
    }
/// Send an asynchronous service request message to the workers.
Send an asynchronous service request message to the workers.
Send an asynchronous service request message to the workers .
pub fn send(&self, msg: AsyncRequestMessage) -> Result<()> {
        match &msg {
            AsyncRequestMessage::FsPrefetch(_, _, req) => {
                if let Some(ref limiter) = self.prefetch_limiter {
                    let size = std::cmp::min(req.blob_size, u32::MAX as u64) as u32;
                    let cells = match NonZeroU32::new(size) {
                        Some(v) => v,
                        None => return Ok(()),
                    };
                    if let Err(e) = limiter
                        .check_n(cells)
                        .or_else(|_| block_on(limiter.until_n_ready(cells)))
                    {
                        // `InsufficientCapacity` is the only possible error
                        // Have to give up to avoid dead-loop
                        error!("{}: give up rate-limiting", e);
                    }
                }
            }
            AsyncRequestMessage::BlobPrefetch(_, _, _, size) => {
                if let Some(ref limiter) = self.prefetch_limiter {
                    let size = std::cmp::min(*size, u32::MAX as u64) as u32;
                    let cells = match NonZeroU32::new(size) {
                        Some(v) => v,
                        None => return Ok(()),
                    };
                    if let Err(e) = limiter
                        .check_n(cells)
                        .or_else(|_| block_on(limiter.until_n_ready(cells)))
                    {
                        // `InsufficientCapacity` is the only possible error
                        // Have to give up to avoid dead-loop
                        error!("{}: give up rate-limiting", e);
                    }
                }
            }
            _ => {}
        }
        let mut sender = self.sender.lock().unwrap();
        sender.send(msg).map_err(|e| {
            warn!("no more receiver for channel, {}", e);
            eio!()
        })
    }
pub fn send ( & self , msg : AsyncRequestMessage ) -> Result < ( ) > { match & msg { AsyncRequestMessage :: FsPrefetch ( _ , _ , req ) => { if let Some ( ref limiter ) = self . prefetch_limiter { let size = std :: cmp :: min ( req . blob_size , u32 :: MAX as u64 ) as u32 ; let cells = match NonZeroU32 :: new ( size ) { Some ( v ) => v , None => return Ok ( ( ) ) , } ; if let Err ( e ) = limiter . check_n ( cells ) . or_else ( | _ | block_on ( limiter . until_n_ready ( cells ) ) ) { // `InsufficientCapacity` is the only possible error // Have to give up to avoid dead-loop error ! ( " " e ) ; } } } AsyncRequestMessage :: BlobPrefetch ( _ , _ , _ , size ) => { if let Some ( ref limiter ) = self . prefetch_limiter { let size = std :: cmp :: min ( * size , u32 :: MAX as u64 ) as u32 ; let cells = match NonZeroU32 :: new ( size ) { Some ( v ) => v , None => return Ok ( ( ) ) , } ; if let Err ( e ) = limiter . check_n ( cells ) . or_else ( | _ | block_on ( limiter . until_n_ready ( cells ) ) ) { // `InsufficientCapacity` is the only possible error // Have to give up to avoid dead-loop error ! ( " " e ) ; } } } _ => { } } let mut sender = self . sender . lock ( ) . unwrap ( ) ; sender . send ( msg ) . map_err ( | e | { warn ! ( " " e ) ; eio ! ( ) } ) }
Send an asynchronous service request message to the workers.
Send an asynchronous service request message to the workers .
&self
msg
AsyncRequestMessage
&self
msg
AsyncRequestMessage