Expand description
The refiller code that is the BandwidthRefiller is a public entity that needs to
run into its own task and refill the associated super::BandwidthPool and serve
any RefillWaiter pending on the pool to be replenished.
§Driving a pool
The refiller must live in its own task that owns the clock and the rate. Simply call
BandwidthRefiller::run into a spawned task. It builds a token bucket from the given
rate + burst and a tor_rtcompat::SleepProvider.
§Example
ⓘ
let (pool, refiller) = BandwidthPool::new(capacity);
let config = TokenBucketConfig { rate, bucket_max: capacity };
runtime.spawn(refiller.run(runtime.clone(), config))?;Structs§
- Bandwidth
Refiller - A bandwidth refiller is in charge of refilling the associated
super::BandwidthPooland processing any pending RefillWaiter that were enqueued by the pool. - Refill
Waiter 🔒 - A refill waiter object through which the
BandwidthRefillersignals a blocked acquirer.
Type Aliases§
- BwRequest 🔒
- A bandwidth request sent on the queue to the
BandwidthRefiller.