The Time class provides basic facilities for getting the current time, constructing time intervals, adding and subtracting times, and comparing times:
Internally, the Time class stores ticks in microsecond units. For absolute time, this is the number of microseconds since the Unix epoch (00:00:00 UTC on 1 Jan. 1970). For durations, this is the number of microseconds in the duration. The default constructor initializes the tick count to zero and selects the real-time clock. Constructing
Time with an argument of
Monotonic selects the monotonic clock on platforms that support it; the real-time clock is used on other platforms.
Using a Time object with a timed lock operation is trivial, for example:
Note that the TryRLock and
TryWLock constructors are overloaded: if you supply only a mutex as the sole argument, the constructor calls
tryReadLock or
tryWriteLock; if you supply both a mutex and a timeout, the constructor calls
timedReadLock or
timedWriteLock.