FairMQ
1.3.9
C++ Message Passing Framework
|
#include <RateLimit.h>
Public Member Functions | |
RateLimiter (float rate) | |
void | maybe_sleep () |
Objects of type RateLimiter can be used to limit a loop to a given rate of iterations per second.
Example:
|
inline |
Constructs a rate limiter.
rate | Work rate in Hz (calls to maybe_sleep per second). Values less than/equal to 0 set the rate to 1 GHz (which is impossible to achieve, even with a loop that only calls RateLimiter::maybe_sleep). |
|
inline |
Call this function at the end of the iteration rate limited loop.
This function might use std::this_thread::sleep_for
to limit the iteration rate. If no sleeps are necessary, the function will back off checking for the time to further allow increased iteration rates (until the requested rate or 1s between rechecks is reached).