libfilezilla
Classes | Public Member Functions | Protected Member Functions | List of all members
bucket Class Reference

A rate-limited token bucket. More...

#include <rate_limiter.hpp>

Inheritance diagram for bucket:
Inheritance graph
[legend]
Collaboration diagram for bucket:
Collaboration graph
[legend]

Public Member Functions

rate::type available (direction::type const d)
 Returns available octets. More...
 
void consume (direction::type const d, rate::type amount)
 Consumes octets. More...
 
- Public Member Functions inherited from bucket_base
void remove_bucket ()
 

Protected Member Functions

virtual void wakeup (direction::type)
 Called in response to unlock_tree if tokens have become available. More...
 
- 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_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.

◆ 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: