SPH
Classes | Functions | Variables
Timer.cpp File Reference
#include "system/Timer.h"
#include <atomic>
#include <iomanip>
#include <mutex>
#include <thread>

Go to the source code of this file.

Classes

class  TimerThread
 

Functions

SharedPtr< TimermakeTimer (const int64_t interval, const std::function< void(void)> &callback, const Flags< TimerFlags > flags)
 Creates timer with given interval and callback when time interval is finished. More...
 
std::string getFormattedTime (int64_t time)
 Returns the human-readable formatted time in suitable units. More...
 

Variables

const int64_t SECOND = 1000
 
const int64_t MINUTE = 60 * SECOND
 
const int64_t HOUR = 60 * MINUTE
 
const int64_t DAY = 24 * HOUR
 

Function Documentation

◆ getFormattedTime()

std::string getFormattedTime ( const int64_t  time)

Returns the human-readable formatted time in suitable units.

Parameters
timeTime in milliseconds

Definition at line 169 of file Timer.cpp.

◆ makeTimer()

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.

Definition at line 97 of file Timer.cpp.

Variable Documentation

◆ DAY

const int64_t DAY = 24 * HOUR

Definition at line 167 of file Timer.cpp.

◆ HOUR

const int64_t HOUR = 60 * MINUTE

Definition at line 166 of file Timer.cpp.

◆ MINUTE

const int64_t MINUTE = 60 * SECOND

Definition at line 165 of file Timer.cpp.

◆ SECOND

const int64_t SECOND = 1000
Todo:
can be improved after units are introduced into the code

Definition at line 164 of file Timer.cpp.