OSVR-Core
|
This provides a level of interoperability with struct timeval on systems with that facility. More...
Namespaces | |
osvr::util::time | |
Functionality related to time and the OSVR_TimeValue abstraction. | |
Classes | |
struct | OSVR_TimeValue |
Standardized, portable parallel to struct timeval for representing both absolute times and time intervals. More... | |
Typedefs | |
typedef int64_t | OSVR_TimeValue_Seconds |
The signed integer type storing the seconds in a struct OSVR_TimeValue. | |
typedef int32_t | OSVR_TimeValue_Microseconds |
The signed integer type storing the microseconds in a struct OSVR_TimeValue. | |
typedef struct OSVR_TimeValue | OSVR_TimeValue |
Standardized, portable parallel to struct timeval for representing both absolute times and time intervals. More... | |
Functions | |
OSVR_UTIL_EXPORT void | osvrTimeValueNormalize (OSVR_INOUT_PTR OSVR_TimeValue *tv) OSVR_FUNC_NONNULL((1)) |
"Normalizes" a time value so that the absolute number of microseconds is less than 1,000,000, and that the sign of both components is the same. More... | |
OSVR_UTIL_EXPORT void | osvrTimeValueSum (OSVR_INOUT_PTR OSVR_TimeValue *tvA, OSVR_IN_PTR const OSVR_TimeValue *tvB) OSVR_FUNC_NONNULL((1 |
Sums two time values, replacing the first with the result. More... | |
OSVR_UTIL_EXPORT void OSVR_UTIL_EXPORT void | osvrTimeValueDifference (OSVR_INOUT_PTR OSVR_TimeValue *tvA, OSVR_IN_PTR const OSVR_TimeValue *tvB) OSVR_FUNC_NONNULL((1 |
Computes the difference between two time values, replacing the first with the result. More... | |
OSVR_UTIL_EXPORT void OSVR_UTIL_EXPORT void OSVR_UTIL_EXPORT int | osvrTimeValueCmp (OSVR_IN_PTR const OSVR_TimeValue *tvA, OSVR_IN_PTR const OSVR_TimeValue *tvB) OSVR_FUNC_NONNULL((1 |
Compares two time values (assumed to be normalized), returning the same values as strcmp. More... | |
OSVR_UTIL_EXPORT void OSVR_UTIL_EXPORT void OSVR_UTIL_EXPORT int OSVR_EXTERN_C_END OSVR_INLINE double | osvrTimeValueDurationSeconds (OSVR_IN_PTR const OSVR_TimeValue *tvA, OSVR_IN_PTR const OSVR_TimeValue *tvB) |
Compute the difference between the two time values, returning the duration as a double-precision floating-point number of seconds. More... | |
OSVR_INLINE OSVR_CBool | osvrTimeValueGreater (OSVR_IN_PTR const OSVR_TimeValue *tvA, OSVR_IN_PTR const OSVR_TimeValue *tvB) |
True if A is later than B. | |
This provides a level of interoperability with struct timeval on systems with that facility.
It provides a neutral representation with sufficiently large types.
For C++ code, use of std::chrono or boost::chrono instead is recommended.
Note that these time values may not necessarily correlate between processes so should not be used to estimate or measure latency, etc.
typedef struct OSVR_TimeValue OSVR_TimeValue |
Standardized, portable parallel to struct timeval for representing both absolute times and time intervals.
Where interpreted as an absolute time, its meaning is to be considered the same as that of the POSIX struct timeval: time since 00:00 Coordinated Universal Time (UTC), January 1, 1970.
For best results, please keep normalized. Output of all functions here is normalized.
OSVR_UTIL_EXPORT void OSVR_UTIL_EXPORT void OSVR_UTIL_EXPORT int osvrTimeValueCmp | ( | OSVR_IN_PTR const OSVR_TimeValue * | tvA, |
OSVR_IN_PTR const OSVR_TimeValue * | tvB | ||
) |
Compares two time values (assumed to be normalized), returning the same values as strcmp.
OSVR_UTIL_EXPORT void OSVR_UTIL_EXPORT void osvrTimeValueDifference | ( | OSVR_INOUT_PTR OSVR_TimeValue * | tvA, |
OSVR_IN_PTR const OSVR_TimeValue * | tvB | ||
) |
Computes the difference between two time values, replacing the first with the result.
Effectively, *tvA = *tvA - *tvB
tvA | Destination and first source. |
tvB | second source |
If a given pointer is NULL, this function returns without doing anything.
Both parameters are expected to be in normalized form.
OSVR_UTIL_EXPORT void OSVR_UTIL_EXPORT void OSVR_UTIL_EXPORT int OSVR_EXTERN_C_END OSVR_INLINE double osvrTimeValueDurationSeconds | ( | OSVR_IN_PTR const OSVR_TimeValue * | tvA, |
OSVR_IN_PTR const OSVR_TimeValue * | tvB | ||
) |
Compute the difference between the two time values, returning the duration as a double-precision floating-point number of seconds.
Effectively, ret = *tvA - *tvB
tvA | first source. |
tvB | second source |
OSVR_UTIL_EXPORT void osvrTimeValueNormalize | ( | OSVR_INOUT_PTR OSVR_TimeValue * | tv | ) |
"Normalizes" a time value so that the absolute number of microseconds is less than 1,000,000, and that the sign of both components is the same.
tv | Address of a struct TimeValue to normalize in place. |
If the given pointer is NULL, this function returns without doing anything.
OSVR_UTIL_EXPORT void osvrTimeValueSum | ( | OSVR_INOUT_PTR OSVR_TimeValue * | tvA, |
OSVR_IN_PTR const OSVR_TimeValue * | tvB | ||
) |
Sums two time values, replacing the first with the result.
tvA | Destination and first source. |
tvB | second source |
If a given pointer is NULL, this function returns without doing anything.
Both parameters are expected to be in normalized form.