|
Click
|
Represents a moment or interval in time. More...
Classes | |
| union | rep_t |
| Type of a Timestamp representation. More... | |
Public Types | |
| enum | { max_seconds = (seconds_type) 2147483647U , min_seconds = (seconds_type) -2147483648U } |
| enum | { nsec_per_sec = 1000000000 , nsec_per_msec = 1000000 , nsec_per_usec = 1000 , usec_per_sec = 1000000 , usec_per_msec = 1000 , msec_per_sec = 1000 , subsec_per_sec = nsec_per_sec , subsec_per_msec = subsec_per_sec / msec_per_sec , subsec_per_usec = subsec_per_sec / usec_per_sec } |
| enum | { NSUBSEC = subsec_per_sec } |
| typedef int32_t | seconds_type |
| Type represents a number of seconds. | |
| typedef int32_t | value_type |
| Return type for msecval(), usecval(), and nsecval(). | |
| typedef uninitialized_type | uninitialized_t |
| typedef seconds_type(Timestamp::* | unspecified_bool_type) () const |
Public Member Functions | |
| Timestamp () | |
| Construct a zero-valued Timestamp. | |
| Timestamp (long sec, uint32_t subsec=0) | |
| Construct a Timestamp of sec seconds plus subsec subseconds. | |
| Timestamp (int sec, uint32_t subsec=0) | |
| Timestamp (unsigned long sec, uint32_t subsec=0) | |
| Timestamp (unsigned sec, uint32_t subsec=0) | |
| Timestamp (double) | |
| Create a timestamp measuring d seconds. | |
| Timestamp (const struct timeval &tv) | |
| Create a Timestamp measuring tv. | |
| Timestamp (const struct timespec &ts) | |
| Create a Timestamp measuring ts. | |
| Timestamp (const rep_t &rep) | |
| Construct a Timestamp from its internal representation. | |
| Timestamp (const uninitialized_t &unused) | |
| Construct an uninitialized timestamp. | |
| operator unspecified_bool_type () const | |
| Return true iff this timestamp is not zero-valued. | |
| bool | is_negative () const |
| Test if this Timestamp is negative (< Timestamp(0, 0)). | |
| seconds_type | sec () const |
| Return this timestamp's seconds component. | |
| uint32_t | subsec () const |
| Return this timestamp's subseconds component. | |
| uint32_t | msec () const |
| Return this timestamp's subseconds component, converted to milliseconds. | |
| uint32_t | usec () const |
| Return this timestamp's subseconds component, converted to microseconds. | |
| uint32_t | nsec () const |
| Return this timestamp's subseconds component, converted to nanoseconds. | |
| void | set_sec (seconds_type sec) |
| Set this timestamp's seconds component. | |
| void | set_subsec (uint32_t subsec) |
| Set this timestamp's subseconds component. | |
| seconds_type | msec1 () const |
| Return this timestamp's interval length, converted to milliseconds. | |
| seconds_type | usec1 () const |
| Return this timestamp's interval length, converted to microseconds. | |
| seconds_type | nsec1 () const |
| Return this timestamp's interval length, converted to nanoseconds. | |
| struct timeval | timeval () const |
| Return a struct timeval that approximates this timestamp. | |
| struct timeval | timeval_ceil () const |
| Return the minimum struct timeval >= this timestamp. | |
| struct timespec | timespec () const |
| Return a struct timespec with the same value as this timestamp. | |
| int64_t | longval () const |
| Return this timestamp's value in subseconds. | |
| void | assignlong (int64_t) |
| double | doubleval () const |
| Return this timestamp's value, converted to a real number. | |
| value_type | msecval () const |
| Return this timestamp's interval length in milliseconds. | |
| value_type | usecval () const |
| Return this timestamp's interval length in microseconds. | |
| value_type | nsecval () const |
| Return this timestamp's interval length in nanoseconds. | |
| Timestamp | msec_ceil () const |
| Return the next millisecond-valued timestamp no smaller than *this. | |
| Timestamp | usec_ceil () const |
| Return the next microsecond-valued timestamp no smaller than *this. | |
| Timestamp | nsec_ceil () const |
| Return the next nanosecond-valued timestamp no smaller than *this. | |
| click_jiffies_t | jiffies () const |
| Return the number of jiffies represented by this timestamp. | |
| void | clear () |
| Clear this timestamp. | |
| void | assign (seconds_type sec, uint32_t subsec=0) |
| void | assign_usec (seconds_type sec, uint32_t usec) |
| void | assign_nsec (seconds_type sec, uint32_t nsec) |
| void | assign_now () |
| Set this timestamp to the current system time. | |
| void | assign_recent () |
| Set this timestamp to a recent system time. | |
| void | assign_now_steady () |
| Set this timestamp to the current steady-clock time. | |
| void | assign_recent_steady () |
| Set this timestamp to a recent steady-clock time. | |
| void | assign_now_nouser (bool steady) |
| Set this timestamp to the current clock time without calling the user clock if one is set. | |
| String | unparse () const |
| Unparse this timestamp into a String. | |
| String | unparse_interval () const |
| Unparse this timestamp into a String as an interval. | |
Static Public Member Functions | |
| static Timestamp | make_jiffies (click_jiffies_t jiffies) |
| Return a timestamp representing an interval of jiffies. | |
| static Timestamp | make_jiffies (click_jiffies_difference_t jiffies) |
| static Timestamp | make_sec (seconds_type sec) |
| Return a timestamp representing sec seconds. | |
| static Timestamp | make_msec (seconds_type sec, uint32_t msec) |
| Return a timestamp representing sec seconds plus msec milliseconds. | |
| static Timestamp | make_msec (value_type msec) |
| Return a timestamp representing msec milliseconds. | |
| static Timestamp | make_usec (seconds_type sec, uint32_t usec) |
| Return a timestamp representing sec seconds plus usec microseconds. | |
| static Timestamp | make_usec (value_type usec) |
| Return a timestamp representing usec microseconds. | |
| static Timestamp | make_nsec (seconds_type sec, uint32_t nsec) |
| Return a timestamp representing sec seconds plus nsec nanoseconds. | |
| static Timestamp | make_nsec (value_type nsec) |
| Return a timestamp representing nsec nanoseconds. | |
| static Timestamp | epsilon () |
| Return the smallest nonzero timestamp, Timestamp(0, 1). | |
| static Timestamp | now () |
| Return the current system time. | |
| static Timestamp | recent () |
| Return a recent system time. | |
| static Timestamp | now_steady () |
| Return the current steady-clock time. | |
| static Timestamp | recent_steady () |
| Return a recent steady-clock time. | |
| static uint32_t | msec_to_subsec (uint32_t msec) |
| Convert milliseconds to subseconds. | |
| static uint32_t | usec_to_subsec (uint32_t usec) |
| Convert microseconds to subseconds. | |
| static uint32_t | nsec_to_subsec (uint32_t nsec) |
| Convert nanoseconds to subseconds. | |
| static uint32_t | subsec_to_msec (uint32_t subsec) |
| Convert subseconds to milliseconds. | |
| static uint32_t | subsec_to_usec (uint32_t subsec) |
| Convert subseconds to microseconds. | |
| static uint32_t | subsec_to_nsec (uint32_t subsec) |
| Convert subseconds to nanoseconds. | |
Related Symbols | |
(Note that these are not member symbols.) | |
| bool | operator== (const Timestamp &a, const Timestamp &b) |
| Compare two timestamps for equality. | |
| bool | operator!= (const Timestamp &a, const Timestamp &b) |
| Compare two timestamps for inequality. | |
| bool | operator< (const Timestamp &a, const Timestamp &b) |
| Compare two timestamps. | |
| bool | operator<= (const Timestamp &a, const Timestamp &b) |
| Compare two timestamps. | |
| bool | operator>= (const Timestamp &a, const Timestamp &b) |
| Compare two timestamps. | |
| bool | operator> (const Timestamp &a, const Timestamp &b) |
| Compare two timestamps. | |
| StringAccum & | operator<< (StringAccum &sa, const Timestamp &ts) |
| Append the unparsed representation of ts to sa. | |
Represents a moment or interval in time.
The Click Timestamp class represents both moments in time and intervals in time. In most Click code, Timestamp replaces the Unix "struct timeval" and "struct timespec" structures; for example, Timer expiry times use the Timestamp class. Timestamps may be added, subtracted, and compared using the usual operators.
Timestamp measures time in seconds, and provides access to seconds and "subseconds", or fractions of a second. Click can be configured with either microsecond or nanosecond precision. Thus, one subsecond might equal either one microsecond or one nanosecond. The subsec_per_sec enumeration constant equals the number of subseconds in a second; the timestamp's subsec() value should always lie between 0 and subsec_per_sec - 1. (The –enable-nanotimestamp configuration option enables nanosecond-precision timestamps at user level; kernel modules use the kernel's native timestamp precision, which in later versions of Linux is nanosecond-precision.)
A Timestamp with sec() < 0 is negative. Note that subsec() is always nonnegative. A Timestamp's value always equals (sec() + subsec() / (double) subsec_per_sec); thus, the Timestamp value of -0.1 is represented as sec() == -1, usec() == +900000.
| typedef int32_t Timestamp::seconds_type |
Type represents a number of seconds.
| typedef int32_t Timestamp::value_type |
| anonymous enum |
| anonymous enum |
|
inline |
Construct a zero-valued Timestamp.
|
inlineexplicit |
Construct a Timestamp of sec seconds plus subsec subseconds.
| sec | number of seconds |
| subsec | number of subseconds (defaults to 0) |
The subsec parameter must be between 0 and subsec_per_sec - 1, and the sec parameter must be between min_seconds and max_seconds . Errors are not necessarily checked.
|
inlineexplicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineexplicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineexplicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineexplicit |
Create a timestamp measuring d seconds.
|
inline |
Create a Timestamp measuring tv.
| tv | timeval structure |
|
inline |
Create a Timestamp measuring ts.
| ts | timespec structure |
|
inline |
Construct a Timestamp from its internal representation.
|
inline |
Construct an uninitialized timestamp.
|
inline |
Return true iff this timestamp is not zero-valued.
|
inline |
Test if this Timestamp is negative (< Timestamp(0, 0)).
|
inline |
Return this timestamp's seconds component.
|
inline |
Return this timestamp's subseconds component.
|
inline |
Return this timestamp's subseconds component, converted to milliseconds.
|
inline |
Return this timestamp's subseconds component, converted to microseconds.
|
inline |
Return this timestamp's subseconds component, converted to nanoseconds.
|
inline |
Set this timestamp's seconds component.
The subseconds component is left unchanged.
|
inline |
Set this timestamp's subseconds component.
| subsec | number of subseconds |
The seconds component is left unchanged.
|
inline |
Return this timestamp's interval length, converted to milliseconds.
Will overflow on intervals of more than 2147483.647 seconds.
|
inline |
Return this timestamp's interval length, converted to microseconds.
Will overflow on intervals of more than 2147.483647 seconds.
|
inline |
Return this timestamp's interval length, converted to nanoseconds.
Will overflow on intervals of more than 2.147483647 seconds.
|
inline |
Return a struct timeval that approximates this timestamp.
If Timestamp and struct timeval have the same size and representation, then this operation returns a "const struct timeval &" whose address is the same as this Timestamp. If Timestamps have nanosecond precision, the conversion rounds down, so Timestamp(t.timeval()) <= t.
|
inline |
|
inline |
|
inline |
Return this timestamp's value in subseconds.
|
inline |
Return this timestamp's value, converted to a real number.
|
inline |
Return this timestamp's interval length in milliseconds.
|
inline |
Return this timestamp's interval length in microseconds.
|
inline |
Return this timestamp's interval length in nanoseconds.
|
inline |
Return the next millisecond-valued timestamp no smaller than *this.
|
inline |
Return the next microsecond-valued timestamp no smaller than *this.
|
inline |
Return the next nanosecond-valued timestamp no smaller than *this.
|
inlinestatic |
Return a timestamp representing an interval of jiffies.
|
inlinestatic |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Return the number of jiffies represented by this timestamp.
|
inlinestatic |
Return a timestamp representing sec seconds.
|
inlinestatic |
Return a timestamp representing sec seconds plus msec milliseconds.
|
inlinestatic |
Return a timestamp representing msec milliseconds.
|
inlinestatic |
Return a timestamp representing sec seconds plus usec microseconds.
|
inlinestatic |
Return a timestamp representing usec microseconds.
|
inlinestatic |
Return a timestamp representing sec seconds plus nsec nanoseconds.
|
inlinestatic |
Return a timestamp representing nsec nanoseconds.
|
inlinestatic |
Return the smallest nonzero timestamp, Timestamp(0, 1).
|
inline |
Clear this timestamp.
|
inline |
Set this timestamp to a seconds-and-subseconds value.
|
inline |
Assign this timestamp to a seconds-and-microseconds value.
|
inline |
Assign this timestamp to a seconds-and-nanoseconds value.
|
inlinestatic |
Return the current system time.
never
System time is measured in seconds since January 1, 1970 GMT. Produces the most precise timestamp available.
|
inline |
Set this timestamp to the current system time.
Like "*this = Timestamp::now()".
|
inlinestatic |
Return a recent system time.
The Timestamp::now() function calculates the current system time, which is relatively expensive. Timestamp::recent() can be faster, but is less precise: it returns a cached copy of a recent system time.
|
inline |
Set this timestamp to a recent system time.
Like "*this = Timestamp::recent()".
|
inlinestatic |
Return the current steady-clock time.
The steady clock, often called a monotonic clock, is a system clock that never moves backwards. Steady-clock time is measured in seconds since an undefined start point (often related to the most recent boot). Produces the most precise timestamp available.
|
inline |
Set this timestamp to the current steady-clock time.
Like "*this = Timestamp::now_steady()".
|
inlinestatic |
Return a recent steady-clock time.
The Timestamp::now_steady() function calculates the current steady-clock time, which is relatively expensive. Timestamp::recent_steady() can be faster, but is less precise: it returns a cached copy of a recent steady-clock time.
|
inline |
Set this timestamp to a recent steady-clock time.
Like "*this = Timestamp::recent_steady()".
|
inline |
Set this timestamp to the current clock time without calling the user clock if one is set.
| String Timestamp::unparse | ( | ) | const |
Unparse this timestamp into a String.
Returns a string formatted like "10.000000", with at least six subsecond digits. (Nanosecond-precision timestamps where the number of nanoseconds is not evenly divisible by 1000 are given nine subsecond digits.)
| String Timestamp::unparse_interval | ( | ) | const |
Unparse this timestamp into a String as an interval.
Returns a string formatted like "1us" or "1.000002s".
|
inlinestatic |
Convert milliseconds to subseconds.
Subseconds are either microseconds or nanoseconds, depending on configuration options and driver choice.
|
inlinestatic |
Convert microseconds to subseconds.
|
inlinestatic |
Convert nanoseconds to subseconds.
|
inlinestatic |
Convert subseconds to milliseconds.
|
inlinestatic |
Convert subseconds to microseconds.
|
inlinestatic |
Convert subseconds to nanoseconds.
Compare two timestamps for equality.
never
Returns true iff the two operands have the same seconds and subseconds components.
Compare two timestamps for inequality.
Returns true iff !(a == b).
Compare two timestamps.
Returns true iff a represents a shorter interval than b, or considered as absolute time, a happened before b.
Compare two timestamps.
Returns true iff a measures an interval no larger than b, or considered as absolute time, a happened at or before b.
Compare two timestamps.
Returns true iff a measures an interval no shorter than b, or considered as absolute time, a happened at or after b.
Compare two timestamps.
Returns true iff a measures a longer interval than b, or considered as absolute time, a happened after b.
|
related |
Append the unparsed representation of ts to sa.
Same as sa << ts.unparse().