OpenVPN 3 Core Library
|
#include <time.hpp>
Classes | |
class | Duration |
Public Types | |
enum | { prec = 1024 } |
typedef ::time_t | base_type |
typedef T | type |
Public Member Functions | |
TimeType () noexcept | |
bool | is_infinite () const |
void | reset () |
void | set_infinite () |
bool | defined () const |
bool | operator! () const |
base_type | seconds_since_epoch () const |
std::uint64_t | nanoseconds_since_epoch () const |
T | fractional_binary_ms () const |
void | update () |
TimeType | operator+ (const Duration &d) const |
TimeType & | operator+= (const Duration &d) |
Duration | operator- (const TimeType &t) const |
void | min (const TimeType &t) |
void | max (const TimeType &t) |
long | delta_prec (const TimeType &t) const |
long | delta (const TimeType &t) const |
double | delta_float (const TimeType &t) const |
std::string | delta_str (const TimeType &t) const |
template<typename HASH > | |
void | hash (HASH &h) const |
T | raw () const |
Static Public Member Functions | |
static TimeType | zero () |
static TimeType | infinite () |
static TimeType | from_seconds_since_epoch (const time_t t) |
static TimeType | now () |
static void | reset_base_conditional () |
static void | reset_base () |
static uint64_t | win_time () |
Private Member Functions | |
TimeType (const T time) | |
Static Private Member Functions | |
static T | now_ () |
Private Attributes | |
T | time_ |
Static Private Attributes | |
static base_type | base_ = 0 |
These are our fundamental Time and Time Duration classes. We normally deal with time in units of 1/1024 of a second. This allows us to use 32-bit values to represent most time and time duration values, but still gives us reasonable accuracy. Using units of 1/1024 of a second vs. straight milliseconds gives us an advantage of not needing to do very much integer multiplication and division which can help us on platforms such as ARM that lack integer division instructions. Note that the data type used to store the time is an oulong, so it will automatically expand to 64 bits on 64-bit machines (see olong.hpp). Using a 32-bit data type for time durations is normally fine for clients, but imposes a wraparound limit of ~ 48 days. Servers should always use a 64-bit data type to avoid this limitation.
This code was originally designed to be efficient on 32-bit processors. On 64-bit processors, define OPENVPN_TIME_NO_BASE to optimize out the base_ variable. This also has the benefit of allowing Time to represent any arbitrary time_t value.
typedef ::time_t openvpn::TimeType< T >::base_type |
typedef T openvpn::TimeType< T >::type |
|
inlinenoexcept |
|
inlineexplicitprivate |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestaticprivate |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
|
inlinestaticprivate |
|
private |