libfilezilla
|
A rate-limited token bucket. More...
#include <rate_limiter.hpp>
Public Member Functions | |
virtual void | remove_bucket () override |
rate::type | available (direction::type const d) |
Returns available octets. More... | |
void | consume (direction::type const d, rate::type amount) |
Consumes octets. More... | |
Protected Member Functions | |
virtual void | wakeup (direction::type) |
Called in response to unlock_tree if tokens have become available. More... | |
bool | waiting (scoped_lock &l, direction::type d) |
Call with the bucket_base mutex lock. | |
Protected Member Functions inherited from bucket_base | |
virtual void | lock_tree () |
Recursively locks the mutexes of self and all children. More... | |
virtual size_t | weight () const |
Returns the weight of the tree. More... | |
virtual void | set_mgr_recursive (rate_limit_manager *mgr) |
Recursively sets the manager. More... | |
Additional Inherited Members | |
Protected Attributes inherited from bucket_base | |
mutex | mtx_ {false} |
rate_limit_manager * | mgr_ {} |
void * | parent_ {} |
size_t | idx_ {static_cast<size_t>(-1)} |
A rate-limited token bucket.
rate::type available | ( | direction::type const | d | ) |
Returns available octets.
If this functions returns 0, the caller should wait until after bucket::wakeup got called.
void consume | ( | direction::type const | d, |
rate::type | amount | ||
) |
Consumes octets.
Only call with a non-zero amount that's less or equal to the number of available octets. Do not call if an unlimited amount of octets is available.
|
overridevirtual |
Removes the bucket from its parent
Reimplemented from bucket_base.
|
inlineprotectedvirtual |
Called in response to unlock_tree if tokens have become available.
Override in derived classes to signal token availability to consumers.
Reimplemented in rate_limited_layer.