This class provides a mechanism that can be used by clients to regulate the frequency at which actions can be taken. The data members of Throttle are currently public to allow for compile-time (aggregate) initialization of Throttle objects having static storage duration (for C++03 compilers that do not provide constexpr).
Declared in <bdlmt_throttle.h>
class Throttle;
| Name | Description |
|---|---|
clockType | Return the system clock type with which this Throttle is configured to observe the passage of time. |
initialize | initialize overloads |
maxSimultaneousActions | Return the maximum number of simultaneous actions for which this Throttle is configured to permit. |
nanosecondsPerAction | Return the time debt, in nanoseconds, that this Throttle is configured to incur for each action permitted. |
nextPermit | Load into the specified result the earliest absolute time (according to system clock configured at initialization) when the specified numActions will next be permitted. Return 0 on success, and a non-zero value (with no effect on result) if this throttle is configured such that numActions will never be permitted (i.e., return an error if numActions > maxSimultaneousActions) or if numActions <= 0. The returned result is an offset from the epoch of the system clock for which this throttle is configured. The behavior is undefined unless this throttle has been initialized (either by calling initialize or using a BDLMT_THROTTLE_INIT* macro). Note that result may be in the past, and this function does not obtain the current time from the system clock. |
requestPermission | requestPermission overloads |
requestPermissionIfValid | requestPermissionIfValid overloads |
| Name | Description |
|---|---|
d_clockType | Clock type (monotonic or realtime) used by this throttle. |
d_maxSimultaneousActions | Total bucket capacity expressed in actions. |
d_nanosecondsPerAction | Nanoseconds consumed by each sustained action. |
d_nanosecondsPerTotalReset | Total bucket capacity expressed in nanoseconds. |
d_prevLeakTime | Effective time of the previous leak operation. |
| Name | Description |
|---|---|
k_TEN_YEARS_NANOSECONDS | Ten years expressed in nanoseconds. |
| Name | Description |
|---|---|
BloombergLP::bdlmt::Throttle_InitHelper | [PRIVATE]This component private meta-function is used to implement the initialization macros. This type provides the following: * Ensures arguments are evaluated at compile time (which won't be the case for floating point arguments) * Enables compile time checks with BSLMF_ASSERT * Handles special cases if 0 is passed for t_MAX_SIMULTANEOUS_ACTIONS or t_NANOSECONDS_PER_ACTION |