#include <OnixS/FIXEngine/FIX/Throttler.h>
Public Member Functions | |
Throttler (size_t messagesCount, size_t intervalInMs=1000) | |
~Throttler () | |
void | throttle () |
size_t | tryThrottle (bool resetWhenDelay=false) |
void | reset (size_t messagesCount, size_t intervalInMs=1000) |
Definition at line 30 of file Throttler.h.
Throttler | ( | size_t | messagesCount, |
size_t | intervalInMs = 1000 |
||
) |
The constructor.
messagesCount | The message limit per time unit. |
intervalInMs | The time interval to limit messages. |
~Throttler | ( | ) |
The destructor.
void reset | ( | size_t | messagesCount, |
size_t | intervalInMs = 1000 |
||
) |
Resets the throttling parameters.
messagesCount | The message limit per time unit. |
intervalInMs | The time interval to limit messages. |
void throttle | ( | ) |
Performs the throttling.
This method must be called before each action that should be throttled. If the count of messages per time unit exceeds the throttling limit, the function will be blocked until the given time interval is passed.
size_t tryThrottle | ( | bool | resetWhenDelay = false | ) |
Checks the throttling.
This method must be called before each action that should be throttled. If the count of messages per time unit exceeds the throttling limit, the function returns the delay (in milliseconds) until the action becomes possible. Otherwise, it returns 0.
resetWhenDelay | The flag indicates if the calculation of messages per throttling interval should be reset and started again when a delay is returned. |