maximum allowed long-term rate per 1000 units of time
maximum acceptable "burst"
source of time; typically 1 unit = 1 ms
a function to call to slow down the calling thread;
must use the same time units as time
Processes a single packet.
Processes a single packet. If the packet is bigger than the current amount of space available in the bucket, this method will sleep for appropriate amount of time, in order to not exceed the target rate.
A leaking bucket rate limiter. It can be used to limit rate of anything, but typically it is used to limit rate of data transfer.
It starts with an empty bucket. When packets arrive, they are added to the bucket. The bucket has a constant size and is leaking at a constant rate. If the bucket overflows, the thread is delayed by the amount of time proportional to the amount of the overflow.
This class is thread safe and lockless.