Click
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
TokenBucketUsecParameters< T > Class Template Reference

Helper class for token bucket rate limiter. More...

#include <click/tokenbucket.hh>

Public Types

typedef T token_type
 The type of tokens. Always unsigned.
 
typedef click_uintmax_t time_point_type
 The type of a time point. Always unsigned.
 
typedef click_intmax_t duration_type
 The type of a difference between time points. Always signed.
 

Static Public Member Functions

static time_point_type now ()
 Return the current time point.
 
static time_point_type time_point (time_point_type t)
 
static duration_type time_monotonic_difference (time_point_type a, time_point_type b)
 Return b - a, assuming that b was measured after a.
 
static bool time_less (time_point_type a, time_point_type b)
 Return true if a happened before b.
 
static unsigned frequency ()
 Return the number of time points per period.
 
static Timestamp timestamp (time_point_type x)
 Return the Timestamp representing a given time point.
 
static Timestamp timestamp (duration_type x)
 Return the Timestamp representing a given tick count.
 

Detailed Description

template<typename T>
class TokenBucketUsecParameters< T >

Helper class for token bucket rate limiter.

Pass this class as the parameter to TokenRateX. TokenBucketUsecParameters measures ticks in units of microseconds. The template parameter is the type of tokens.

Member Typedef Documentation

◆ token_type

template<typename T >
typedef T TokenBucketUsecParameters< T >::token_type

The type of tokens. Always unsigned.

◆ time_point_type

template<typename T >
typedef click_uintmax_t TokenBucketUsecParameters< T >::time_point_type

The type of a time point. Always unsigned.

◆ duration_type

template<typename T >
typedef click_intmax_t TokenBucketUsecParameters< T >::duration_type

The type of a difference between time points. Always signed.

Member Function Documentation

◆ now()

template<typename T >
static time_point_type TokenBucketUsecParameters< T >::now ( )
inlinestatic

Return the current time point.

Note
TokenBucketUsecParameters measures time points in microseconds.

◆ time_monotonic_difference()

template<typename T >
static duration_type TokenBucketUsecParameters< T >::time_monotonic_difference ( time_point_type  a,
time_point_type  b 
)
inlinestatic

Return b - a, assuming that b was measured after a.

Some time measurements can, in rare cases, appear to jump backwards, as timestamps do when the user changes the current time. If this happens, and b < a (even though b happened after a), time_monotonic_difference must return 0.

◆ time_less()

template<typename T >
static bool TokenBucketUsecParameters< T >::time_less ( time_point_type  a,
time_point_type  b 
)
inlinestatic

Return true if a happened before b.

◆ frequency()

template<typename T >
static unsigned TokenBucketUsecParameters< T >::frequency ( )
inlinestatic

Return the number of time points per period.

Here, this is the number of microseconds per second.

◆ timestamp() [1/2]

template<typename T >
static Timestamp TokenBucketUsecParameters< T >::timestamp ( time_point_type  x)
inlinestatic

Return the Timestamp representing a given time point.

◆ timestamp() [2/2]

template<typename T >
static Timestamp TokenBucketUsecParameters< T >::timestamp ( duration_type  x)
inlinestatic

Return the Timestamp representing a given tick count.


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