nmsg 1.1.2
|
Rate-limiting. More...
Go to the source code of this file.
Functions | |
nmsg_rate_t | nmsg_rate_init (unsigned rate, unsigned freq) |
Initialize a new nmsg_rate_t object. | |
void | nmsg_rate_destroy (nmsg_rate_t *r) |
Destroy an nmsg_rate_t object. | |
void | nmsg_rate_sleep (nmsg_rate_t r) |
Sleep if necessary to maintain the target rate limit. | |
Rate-limiting.
Tight loops can be slowed down by repeated calls to nmsg_rate_sleep(). This works best when the amount of time elapsed between successive calls is approximately the same.
Reliability:
Definition in file rate.h.
nmsg_rate_t nmsg_rate_init | ( | unsigned | rate, |
unsigned | freq | ||
) |
Initialize a new nmsg_rate_t object.
'freq' should usually be about 1-10% of 'rate'.
[in] | rate | target rate limit in Hz, greater than 0. |
[in] | freq | how often the rate limit will be checked, i.e., every 'freq' calls to nmsg_rate_sleep(), greater than 0. |
void nmsg_rate_destroy | ( | nmsg_rate_t * | r | ) |
Destroy an nmsg_rate_t object.
[in] | r | pointer to an nmsg_rate_t object. |
void nmsg_rate_sleep | ( | nmsg_rate_t | r | ) |
Sleep if necessary to maintain the target rate limit.
[in] | r | nmsg_rate_t object. |