![]() |
libfilezilla
|
A limiter for the attached buckets. More...
#include <rate_limiter.hpp>
Public Member Functions | |
rate_limiter (rate_limit_manager *mgr) | |
void | add (bucket_base *bucket) |
Adds a bucket to the limiter. More... | |
void | set_limits (rate::type download_limit, rate::type upload_limit) |
Sets the number of octets all buckets combined may consume each second. More... | |
rate::type | limit (direction::type const d) |
Returns current limit. | |
![]() | |
virtual void | remove_bucket () |
Friends | |
class | bucket_base |
class | rate_limit_manager |
Additional Inherited Members | |
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... | |
![]() | |
mutex | mtx_ {false} |
rate_limit_manager * | mgr_ {} |
void * | parent_ {} |
size_t | idx_ {static_cast<size_t>(-1)} |
A limiter for the attached buckets.
Distributes tokens fairly between buckets, with overflow distributed so that the total limit is not exceeded.
Limiters can either be added to rate_limit_manager, or as sub-limiter to another limiter. For leaf buckets, the actual rate limit is the lowest limit imposed by any of its parents.
void add | ( | bucket_base * | bucket | ) |
Adds a bucket to the limiter.
Child buckets get removed automatically when they are destroyed, or manually when the child's remove_bucket
is called.
void set_limits | ( | rate::type | download_limit, |
rate::type | upload_limit | ||
) |
Sets the number of octets all buckets combined may consume each second.
Pass rate::unlimited
if there should be no limit.
The default limit is rate::unlimited
.