/// Throttle the current task, consuming a specific amount of tokens and
/// possibly blocking until tokens are available
///
/// # Returns
/// the amount of tokens remaining
Throttle the current task, consuming a specific amount of tokens and
possibly blocking until tokens are available
Throttle the current task consuming a specific amount of tokens and possibly blocking until tokens are available
pub async fn throttle(&mut self, tokens: u64) -> u64 {
        loop {
            match self.consume(tokens) {
                Ok(rem) => return rem,
                Err(time) => {
                    log::debug!("blocking for: {:.3?}", time);
                    tokio::time::delay_for(time).await
                }
            }
        }
    }
pub async fn throttle ( & mut self , tokens : u64 ) -> u64 { loop { match self . consume ( tokens ) { Ok ( rem ) => return rem , Err ( time ) => { log :: debug ! ( " " time ) ; tokio :: time :: delay_for ( time ) . await } } } }
Throttle the current task, consuming a specific amount of tokens and
possibly blocking until tokens are available
Throttle the current task consuming a specific amount of tokens and possibly blocking until tokens are available
the amount of tokens remaining
the amount of tokens remaining
&mut self
tokens
u64