Go to the documentation of this file.
27 std::chrono::microseconds timestamp_usec;
35 timestamp_usec = std::chrono::milliseconds{timeServer->getTime()};
46 timestamp_usec = std::chrono::time_point_cast<std::chrono::microseconds>(
47 std::chrono::system_clock::now())
53 timestamp_usec = std::chrono::time_point_cast<std::chrono::microseconds>(
54 std::chrono::steady_clock::now())
60 throw std::runtime_error{
"Cannot asses current time from unknown clock."};
64 const std::string hostname = []{
65 char hostname[HOST_NAME_MAX];
66 gethostname(hostname, HOST_NAME_MAX);
67 return std::string(hostname);
99 return Clock::_virtualClock.
now();
106 Clock::_virtualClock.
waitFor(duration);
113 return Clock::_virtualClock.
waitUntil(dateTime);
static void SleepUS(float microseconds)
static void WaitFor(const Duration &duration)
Wait for a certain duration on the virtual clock.
Duration waitUntil(const DateTime &dateTime) const
Wait and block until the given date/time is surpassed.
Clock to get date/time from a specific clock type or wait for certain durations or until certain date...
bool isPositive() const
Tests whether the duration is positive (value in µs > 0).
static LocalTimeServerPtr GetTimeServer()
ClockType
Describes the type of clock.
@ Unknown
Unknown source of time.
@ Realtime
Normalized time as reported by the operating system.
Clock(ClockType clockType=ClockType::Virtual)
Constructs a new clock of given clock type (virtual by default).
void waitFor(const Duration &duration) const
Wait for a certain duration.
@ Virtual
Time given by time server if configured, realtime otherwise.
Represents a point in time.
static Duration WaitUntil(const DateTime &dateTime)
Wait and block until the given date/time is surpassed on the virtual clock.
static DateTime Now()
Current time on the virtual clock.
std::int64_t toMicroSeconds() const
Returns the amount of microseconds.
static Duration MicroSeconds(std::int64_t microSeconds)
Constructs a duration in microseconds.
@ Monotonic
Monotonic/steady clock of the operating system.
std::chrono::system_clock Clock
DateTime now() const
Current date/time of the clock.