Aleph-w 7.10.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 <cassert>
#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 63 of file ah-time.H.

◆ EVENT_SEC

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

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

◆ EVENT_TIME

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

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

◆ MSEC

#define MSEC   1000

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

◆ NSEC

#define NSEC   1000000000

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

◆ USEC

#define USEC   1000000

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

Typedef Documentation

◆ Time

typedef struct timespec Time

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

Function Documentation

◆ msec_to_nsec()

long msec_to_nsec ( const long &  msec)
inline

Definition at line 66 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 143 of file ah-time.H.

References l, NSEC, and r.

Referenced by demo_event_simulation(), main(), Aleph::AlphaShape::operator()(), and TEST().

◆ operator<=()

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

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

References l, NSEC, and r.

◆ operator==()

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

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

References l, NSEC, and r.

Referenced by Aleph::AlphaShape::operator()().

◆ operator>()

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

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

References l, and r.

◆ operator>=()

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

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

References l, and r.

◆ 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 113 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 82 of file ah-time.H.

◆ timeval_to_time()

Time timeval_to_time ( const struct timeval &  current_time)
inline

Definition at line 90 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 74 of file ah-time.H.

References MSEC, and USEC.

Referenced by timeval_to_time().