pub struct HTB<T> {
pub unit_cost: usize,
/* private fields */
}
Expand description
Hierarchical Token Bucket structure
You can advance time for HTB structure using advance
and
advance_ns
and examine/alter internal state using
peek
/take
.
When several buckets are feeding from a single parent earlier one gets a priority
Fields
unit_cost: usize
Normalized unit cost
Implementations
Create HTB for a given bucket configuration
Buckets should be given in depth first search traversal order:
- root with
parent
set to None - higher priority child of the root
- followed by high priority child of the child, if any, etc.
- followed by the next child
Advance time by number of nanoseconds
Updates internal structure, see also advance
Performance
Update cost is O(N) where N is number of buckets
Advance time by Duration
Updates internal structure, see also advance_ns
Check if there’s at least one token available at index T
See also peek_n
Check if there’s at least cnt
tokens available at index T
See also peek