3.10. Time¶
Time representation.
DefinesFunctionsTIME_BUFSIZE
String buffer minimum size.
INVALID_TIME
Static initializer for the struct time.
Variablesvoid time_build(struct time * t, double secs)Build a new time structure from a number of seconds.
Get a current timestamp.
Add two time object.
Compute the difference between two time object. It returns the result of time_cmp(t1, t2).
Divide two time value.
Multiply a time value.
Compare two time object. It returns -1, 1 or 0 respectivelly if t1 is smaller than t2, t1 is larger than t2 or t1 is equal to t2.
double time_sec(const struct time * t)Convert time to a number of seconds.
Convert time to a string.
- See
- TIME_BUFSIZE
Convert time to a formated string.
- See
- strftime()
Check if the time is valid.
struct time invalid_time
class time
Time structure.
Public Members
3.11. Timer¶
Timer functions.
TypedefsEnumstypedef void(* timer_callback)(int count, void *data)
Opaque timer structure. Timer callback called whenever a timer triggers.
Functionstime_realm_mode enum
Timer mode.
Values:
- TIME_REALM_REALTIME -
- TIME_REALM_STATIC -
Create a new time realm.
bool time_realm_destroy(struct time_realm * realm)Destroy a time realm.
void time_realm_update_and_check(struct time_realm * realm, const struct time * value)Update the time of a time realm that is in TIMER_REALM_STATIC mode. It does also check for timer to trigger.
struct time * time_realm_current_time(struct time_realm * realm)Get the current local time of the time realm.
struct timer * time_realm_timer(struct time_realm * realm, timer_callback callback, void * user)Create a new timer.
bool time_realm_check(struct time_realm * realm)Check and execute timer callbacks.
bool timer_init_thread()Initialize the current thread for timer support.
- Return
- false if an error occurred.
void timer_destroy(struct timer * timer)Destroy a timer.
Start a timer to be trigger only once.
- Return
- false if an error occurred.
Start a timer to be repeated until it is stopped or destroyed.
- Return
- false if an error occurred.
bool timer_stop(struct timer * timer)Stop a timer.
- Return
- false if an error occurred.
class time_realm
Opaque timer environment structure.
Public Members