fn auto_replenish(&mut self) {
        // Compute time passed since last refill/update.
        let time_delta = self.last_update.elapsed().as_nanos() as u64;
        self.last_update = Instant::now();

        // At each 'time_delta' nanoseconds the bucket should refill with:
        // refill_amount = (time_delta * size) / (complete_refill_time_ms * 1_000_000)
        // `processed_capacity` and `processed_refill_time` are the result of simplifying above
        // fraction formula with their greatest-common-factor.
        let tokens = (time_delta * self.processed_capacity) / self.processed_refill_time;
        self.budget = std::cmp::min(self.budget + tokens, self.size);
    }
// Replenishes token bucket based on elapsed time. Should only be called internally by `Self`.
Replenishes token bucket based on elapsed time. Should only be called internally by `Self`.
Replenishes token bucket based on elapsed time . Should only be called internally by ` Self ` .
fn auto_replenish(&mut self) {
        // Compute time passed since last refill/update.
        let time_delta = self.last_update.elapsed().as_nanos() as u64;
        self.last_update = Instant::now();
        // At each 'time_delta' nanoseconds the bucket should refill with:
        // refill_amount = (time_delta * size) / (complete_refill_time_ms * 1_000_000)
        // `processed_capacity` and `processed_refill_time` are the result of simplifying above
        // fraction formula with their greatest-common-factor.
        let tokens = (time_delta * self.processed_capacity) / self.processed_refill_time;
        self.budget = std::cmp::min(self.budget + tokens, self.size);
    }
fn auto_replenish ( & mut self ) { // Compute time passed since last refill/update. let time_delta = self . last_update . elapsed ( ) . as_nanos ( ) as u64 ; self . last_update = Instant :: now ( ) ; // At each 'time_delta' nanoseconds the bucket should refill with: // refill_amount = (time_delta * size) / (complete_refill_time_ms * 1_000_000) // `processed_capacity` and `processed_refill_time` are the result of simplifying above // fraction formula with their greatest-common-factor. let tokens = ( time_delta * self . processed_capacity ) / self . processed_refill_time ; self . budget = std :: cmp :: min ( self . budget + tokens , self . size ) ; }
Replenishes token bucket based on elapsed time.
Replenishes token bucket based on elapsed time .
&mut self
&mut self