![]() |
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... | |
| virtual void | remove_bucket () |
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 void | update_stats (bool &active)=0 |
| Updates weight and usage statistics. More... | |
| virtual size_t | weight () const |
| Returns the weight of the tree. More... | |
| virtual size_t | unsaturated (direction::type const) const |
| Returns the number of buckets not yet full. More... | |
| virtual void | set_mgr_recursive (rate_limit_manager *mgr) |
| Recursively sets the manager. More... | |
| virtual rate::type | add_tokens (direction::type const, rate::type, rate::type)=0 |
| Recursively adds tokens. More... | |
| virtual rate::type | distribute_overflow (direction::type const, rate::type) |
| Recursively distributes overflow. More... | |
| virtual void | unlock_tree () |
| Recursively unlocks the mutexes of self and all children. | |
| virtual std::array< rate::type, 2 > | gather_unspent_for_removal ()=0 |
| Gather unspent tokens during removal to repay debt. 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.