![]() |
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. | |
void | consume (direction::type const d, rate::type amount) |
Consumes octets. | |
Protected Member Functions | |
virtual void | wakeup (direction::type) |
Called in response to unlock_tree if tokens have become available. | |
bool | waiting (scoped_lock &l, direction::type d) |
Call with the bucket_base mutex lock. | |
![]() | |
virtual void | lock_tree () |
Recursively locks the mutexes of self and all children. | |
virtual size_t | weight () const |
Returns the weight of the tree. | |
virtual void | set_mgr_recursive (rate_limit_manager *mgr) |
Recursively sets the manager. | |
Additional Inherited Members | |
![]() | |
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.
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.
Removes the bucket from its parent
Reimplemented from bucket_base.
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.