SPH
|
Measuring time intervals and executing periodic events. More...
#include "objects/containers/Array.h"
#include "objects/wrappers/Flags.h"
#include "objects/wrappers/SharedPtr.h"
#include <chrono>
#include <functional>
Go to the source code of this file.
Classes | |
class | Timer |
Basic time-measuring tool. Starts automatically when constructed. More... | |
class | StoppableTimer |
Simple extension of Timer allowing to pause and continue timer. More... | |
Enumerations | |
enum class | TimerFlags { PERIODIC = 1 << 0 , START_EXPIRED = 1 << 1 } |
enum class | TimerUnit { SECOND , MILLISECOND , MICROSECOND , NANOSECOND } |
Functions | |
SharedPtr< Timer > | makeTimer (const int64_t interval, const std::function< void(void)> &callback, const Flags< TimerFlags > flags=EMPTY_FLAGS) |
Creates timer with given interval and callback when time interval is finished. More... | |
std::string | getFormattedTime (const int64_t time) |
Returns the human-readable formatted time in suitable units. More... | |
|
strong |
|
strong |
std::string getFormattedTime | ( | const int64_t | time | ) |
SharedPtr<Timer> makeTimer | ( | const int64_t | interval, |
const std::function< void(void)> & | callback, | ||
const Flags< TimerFlags > | flags = EMPTY_FLAGS |
||
) |
Creates timer with given interval and callback when time interval is finished.
The callback is executed only once by default, or periodically if TimerFlags::PERIODIC flag is passed. If the timer is destroyed before the interval passes, no callback is called.