provides utility functions for getting the current time
More...
#include <ArmarXCore/core/time/TimeUtil.h>
|
| static IceUtil::Time | GetTime (bool forceSystemTime) |
| | get the current time
|
| |
| static IceUtil::Time | GetTime (TimeMode timeMode=TimeMode::VirtualTime) |
| | Get the current time.
|
| |
| static LocalTimeServerPtr | GetTimeServer () |
| |
| static IceUtil::Time | GetTimeSince (IceUtil::Time referenceTime, bool forceSystemTime) |
| | Get the difference between the current time and a reference time.
|
| |
| static IceUtil::Time | GetTimeSince (IceUtil::Time referenceTime, TimeMode timeMode=TimeMode::VirtualTime) |
| | Get the difference between the current time and a reference time.
|
| |
| static bool | HasTimeServer () |
| | check if we have been initialized with a Timeserver
|
| |
| static void | MSSleep (int durationMS) |
| | lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
|
| |
| static int | NanoSleep (long usec) |
| | Nanosleep convenience function.
|
| |
| static void | SetTimeServer (LocalTimeServerPtr ts) |
| |
| static void | Sleep (float seconds) |
| |
| static void | Sleep (IceUtil::Time duration) |
| | lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
|
| |
| template<class Rep, class Period> |
| static void | Sleep (std::chrono::duration< Rep, Period > d) |
| | lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
|
| |
| static void | SleepMS (float milliseconds) |
| |
| static void | SleepUS (float microseconds) |
| |
| static std::string | toStringDate (const IceUtil::Time &time) |
| | Return a date string like "2020-01-31" (Y-M-D).
|
| |
| static std::string | toStringDateTime (const IceUtil::Time &time) |
| | Return a date & time string like "2020-01-31_15-30-05" (Y-M-D_H-M-S).
|
| |
| static std::string | toStringTime (const IceUtil::Time &time) |
| | Return a time string like "15-30-05" (H-M-S).
|
| |
| static int | USleep (long usec) |
| | like timed_wait on boost condition_variables, but with timeserver support
|
| |
| static void | WaitForNextTick () |
| | block until the next tick of the timeserver.
|
| |
provides utility functions for getting the current time
◆ TimeUtil()
◆ GetTime() [1/2]
| IceUtil::Time GetTime |
( |
bool | forceSystemTime | ) |
|
|
static |
get the current time
- Parameters
-
| forceSystemTime | If true, this function will always return the time of the system and never the virtual time. |
- Returns
- the current time
Depending on if a TimeServer is used, the system time or the TimeServer time is returned
◆ GetTime() [2/2]
Get the current time.
- Parameters
-
| timeMode | Time mode to be used. |
- Returns
- The current time considering timeMode
◆ GetTimeServer()
◆ GetTimeSince() [1/2]
| IceUtil::Time GetTimeSince |
( |
IceUtil::Time | referenceTime, |
|
|
bool | forceSystemTime ) |
|
static |
Get the difference between the current time and a reference time.
- Parameters
-
| referenceTime | Reference point in time. |
| forceSystemTime | If true, this function will always return the time of the system and never the virtual time. |
- Returns
- Current timestamp minus the given reference time to get the delta.
◆ GetTimeSince() [2/2]
Get the difference between the current time and a reference time.
- Parameters
-
| referenceTime | Reference point in time. |
| timeMode | Time mode to be used. |
- Returns
- Current timestamp minus the given reference time to get the delta.
◆ HasTimeServer()
check if we have been initialized with a Timeserver
◆ MSSleep()
| void MSSleep |
( |
int | durationMS | ) |
|
|
static |
lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
- Parameters
-
| durationMS | how long to sleep in milliseconds |
◆ NanoSleep()
| int NanoSleep |
( |
long | usec | ) |
|
|
static |
Nanosleep convenience function.
- Note
- This function does not use virtual time!
◆ SetTimeServer()
◆ Sleep() [1/3]
| static void Sleep |
( |
float | seconds | ) |
|
|
inlinestatic |
◆ Sleep() [2/3]
| void Sleep |
( |
IceUtil::Time | duration | ) |
|
|
static |
lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
- Parameters
-
| duration | how long to sleep |
Sleep for the given duration using timeserver time. Granularity is limited to 1 ms when a Timeserver is running (else 1 us).
◆ Sleep() [3/3]
template<class Rep, class Period>
| static void Sleep |
( |
std::chrono::duration< Rep, Period > | d | ) |
|
|
inlinestatic |
lock the calling thread for a given duration (like usleep(...) but using Timeserver time)
- Parameters
-
| duration | how long to sleep |
Sleep for the given duration using timeserver time. Granularity is limited to 1 ms when a Timeserver is running (else 1 us).
◆ SleepMS()
| static void SleepMS |
( |
float | milliseconds | ) |
|
|
inlinestatic |
◆ SleepUS()
| static void SleepUS |
( |
float | microseconds | ) |
|
|
inlinestatic |
◆ toStringDate()
| std::string toStringDate |
( |
const IceUtil::Time & | time | ) |
|
|
static |
Return a date string like "2020-01-31" (Y-M-D).
◆ toStringDateTime()
| std::string toStringDateTime |
( |
const IceUtil::Time & | time | ) |
|
|
static |
Return a date & time string like "2020-01-31_15-30-05" (Y-M-D_H-M-S).
◆ toStringTime()
| std::string toStringTime |
( |
const IceUtil::Time & | time | ) |
|
|
static |
Return a time string like "15-30-05" (H-M-S).
◆ USleep()
like timed_wait on boost condition_variables, but with timeserver support
The implementation only checks for timeout periodically (see granularity parameter), so precision is limited
- Parameters
-
| cond | the boost::condition_variable to wait on (as shared_ptr) |
| lock | an already locked unique_lock |
| duration | timeout |
| granularity | how often timeout is checked, default is to use a tenth of duration |
- Returns
- false, if the thread was unlocked due to a timeout, else true Usleep convenience function that uses internally nanosleep.
- Note
- This function does not use virtual time!
◆ WaitForNextTick()
block until the next tick of the timeserver.
Noop if no timeserver in use.
Can be used to pause execution if the timeserver is paused. If the timeserver is runing, this may block for up to one tick interval (typically 1ms).
◆ timeServerPtr
The documentation for this class was generated from the following files: