|
dxFeed Graal CXX API v9.0.0
|
A simple thread-safe timer. More...
#include <Timer.hpp>
Public Member Functions | |
| void | interruptableSleep (std::chrono::milliseconds ms) const |
| Sleeps for the specified time or until the timer is stopped. | |
| void | interruptableSleep (std::uint64_t ms) const |
| Sleeps for the specified number of milliseconds or until the timer is stopped. | |
| void | stop () |
| Stops the timer: the function is not run any more and the sleeping thread wakes up. | |
| bool | isRunning () |
Static Public Member Functions | |
| template<typename F, typename Delay, typename Period> | |
| static std::shared_ptr< Timer > | schedule (F &&f, Delay &&delay, Period &&period) |
| Runs the function on a separate thread after the delay and then with the period until the timer is stopped or the function throws. | |
| template<typename F, typename Delay> | |
| static std::shared_ptr< Timer > | runOnce (F &&f, Delay &&delay) |
| Runs the function once on a separate thread after the delay, unless the timer is stopped before. | |
A simple thread-safe timer.
| void Timer::interruptableSleep | ( | std::chrono::milliseconds | ms | ) | const |
Sleeps for the specified time or until the timer is stopped.
| ms | The time to sleep. |
| void Timer::interruptableSleep | ( | std::uint64_t | ms | ) | const |
Sleeps for the specified number of milliseconds or until the timer is stopped.
| ms | The number of milliseconds to sleep. |
| bool Timer::isRunning | ( | ) |
|
inlinestatic |
Runs the function once on a separate thread after the delay, unless the timer is stopped before.
| F | The type of the function. |
| Delay | The type of the delay: a std::chrono::duration or a number of milliseconds. |
| f | The function. |
| delay | The delay before the run. |
|
inlinestatic |
Runs the function on a separate thread after the delay and then with the period until the timer is stopped or the function throws.
| F | The type of the function. |
| Delay | The type of the delay: a std::chrono::duration or a number of milliseconds. |
| Period | The type of the period: a std::chrono::duration or a number of milliseconds. |
| f | The function. |
| delay | The delay before the first run. |
| period | The period between the runs. |