libfilezilla
Loading...
Searching...
No Matches
bucket Class Reference

A rate-limited token bucket. More...

#include <rate_limiter.hpp>

Inheritance diagram for bucket:
Collaboration diagram for bucket:

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.
Protected Member Functions inherited from bucket_base
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

Protected Attributes inherited from bucket_base
mutex mtx_ {false}
rate_limit_managermgr_ {}
void * parent_ {}
size_t idx_ {static_cast<size_t>(-1)}

Detailed Description

A rate-limited token bucket.

Member Function Documentation

◆ available()

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.

◆ consume()

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.

◆ remove_bucket()

virtual void remove_bucket ( )
overridevirtual

Removes the bucket from its parent

Warning
You MUST call this function in the destructor of the most derived class

Reimplemented from bucket_base.

◆ wakeup()

virtual void wakeup ( direction::type )
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.


The documentation for this class was generated from the following file: