29 using Clock = std::chrono::system_clock;
67 const std::function<
void(
void)>& callback,
Generic dynamically allocated resizable storage.
Wrapper over enum allowing setting (and querying) individual bits of the stored value.
const EmptyFlags EMPTY_FLAGS
#define NAMESPACE_SPH_END
@ SECOND
Quantity with 1st and 2nd derivative.
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.
@ START_EXPIRED
Creates expired timer, calling elapsed immediately after creating will return the timer interval.
@ PERIODIC
Timer will execute callback periodically.
std::string getFormattedTime(const int64_t time)
Returns the human-readable formatted time in suitable units.
constexpr INLINE bool has(const TEnum flag) const
Checks if the object has a given flag.
Simple extension of Timer allowing to pause and continue timer.
int64_t elapsed(const TimerUnit unit) const
Returns elapsed time in timer units. Does not reset the timer.
void stop()
Stops the timer. Function getElapsed() will report the same value from now on.
void resume()
Resumes stopped timer.
Basic time-measuring tool. Starts automatically when constructed.
std::chrono::system_clock Clock
bool isExpired() const
Checks if the interval has already passed.
std::chrono::time_point< Clock > TimePoint
int64_t elapsed(const TimerUnit unit) const
Returns elapsed time in timer units. Does not reset the timer.
void restart()
Reset elapsed duration to zero.
Timer(const int64_t interval=0, const Flags< TimerFlags > flags=EMPTY_FLAGS)
Creates timer with given expiration duration.
Flags< TimerFlags > flags
@ PERIODIC
Periodic boundary conditions.