Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-time.H File Reference

Low-level time utilities using POSIX timespec. More...

#include <sys/time.h>
#include <stdio.h>
Include dependency graph for ah-time.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MSEC   1000
 
#define USEC   1000000
 
#define NSEC   1000000000
 
#define EVENT_TIME(e)   ((e)->get_key())
 
#define EVENT_SEC(e)   (EVENT_TIME(e).tv_sec)
 
#define EVENT_NSEC(e)   (EVENT_TIME(e).tv_nsec)
 

Typedefs

typedef struct timespec Time
 

Functions

long msec_to_nsec (const long &msec)
 
long usec_to_nsec (const long &usec)
 
char * time_to_char (const Time &t, char *str, size_t str_size=64)
 
Time timeval_to_time (const struct timeval &current_time)
 
Time read_current_time ()
 
Time time_plus_msec (const Time &current_time, const int &msec)
 
bool operator== (const Time &l, const Time &r)
 
bool operator< (const Time &l, const Time &r)
 
bool operator<= (const Time &l, const Time &r)
 
bool operator> (const Time &l, const Time &r)
 
bool operator>= (const Time &l, const Time &r)
 

Detailed Description

Low-level time utilities using POSIX timespec.

Provides Time type and macros for time arithmetic using struct timespec. Includes conversion macros for milliseconds, microseconds, and nanoseconds.

Author
Leandro Rabindranath León

Definition in file ah-time.H.

Macro Definition Documentation

◆ EVENT_NSEC

#define EVENT_NSEC (   e)    (EVENT_TIME(e).tv_nsec)

Definition at line 62 of file ah-time.H.

◆ EVENT_SEC

#define EVENT_SEC (   e)    (EVENT_TIME(e).tv_sec)

Definition at line 61 of file ah-time.H.

◆ EVENT_TIME

#define EVENT_TIME (   e)    ((e)->get_key())

Definition at line 58 of file ah-time.H.

◆ MSEC

#define MSEC   1000

Definition at line 53 of file ah-time.H.

◆ NSEC

#define NSEC   1000000000

Definition at line 55 of file ah-time.H.

◆ USEC

#define USEC   1000000

Definition at line 54 of file ah-time.H.

Typedef Documentation

◆ Time

typedef struct timespec Time

Definition at line 50 of file ah-time.H.

Function Documentation

◆ msec_to_nsec()

long msec_to_nsec ( const long &  msec)
inline

Definition at line 65 of file ah-time.H.

References MSEC, and USEC.

Referenced by time_plus_msec().

◆ operator<()

bool operator< ( const Time l,
const Time r 
)
inline

Definition at line 142 of file ah-time.H.

References l, and NSEC.

Referenced by demo_event_simulation(), main(), and TEST().

◆ operator<=()

bool operator<= ( const Time l,
const Time r 
)
inline

Definition at line 154 of file ah-time.H.

References l, and NSEC.

◆ operator==()

bool operator== ( const Time l,
const Time r 
)
inline

Definition at line 133 of file ah-time.H.

References l, and NSEC.

◆ operator>()

bool operator> ( const Time l,
const Time r 
)
inline

Definition at line 166 of file ah-time.H.

References l.

◆ operator>=()

bool operator>= ( const Time l,
const Time r 
)
inline

Definition at line 172 of file ah-time.H.

References l.

◆ read_current_time()

Time read_current_time ( )
inline

◆ time_plus_msec()

Time time_plus_msec ( const Time current_time,
const int &  msec 
)
inline

Definition at line 112 of file ah-time.H.

References MSEC, msec_to_nsec(), NSEC, and sec().

Referenced by TimeoutQueue::schedule_after_ms(), time_from_now_ms(), and time_from_now_ms().

◆ time_to_char()

char * time_to_char ( const Time t,
char *  str,
size_t  str_size = 64 
)
inline

Definition at line 81 of file ah-time.H.

◆ timeval_to_time()

Time timeval_to_time ( const struct timeval &  current_time)
inline

Definition at line 89 of file ah-time.H.

References NSEC, USEC, and usec_to_nsec().

Referenced by read_current_time().

◆ usec_to_nsec()

long usec_to_nsec ( const long &  usec)
inline

Definition at line 73 of file ah-time.H.

References MSEC, and USEC.

Referenced by timeval_to_time().