Typedefs | |
typedef ix_timer_s | ix_timer_t |
the timer class | |
typedef itimerval | ix_timer_val_t |
timer value | |
Enumerations | |
enum | ix_timer_type_e { IX_TIMER_ABSOLUTE = 0x20, IX_TIMER_PERIODIC = 0x40, IX_TIMER_ONESHOT = 0x80, IX_TIMER_NORMAL = 0x100 } |
Functions | |
int | ix_timer_val_init (ix_timer_val_t *ptv, int v_sec, int v_usec, int i_sec, int i_usec) |
void | ix_get_timenow (struct timeval *ptv) |
timeval | ix_timer_add (struct timeval *pt1, struct timeval *pt2) |
ix_timer_t * | ix_timer_new (ix_event_t *pev, ix_timer_type_e type, unsigned long userid, void(*cb)(void *parg), void *parg, ix_timer_val_t *pitv) |
int | ix_timer_free (ix_timer_t *pt) |
int | ix_timer_cancel (ix_timer_t *pt) |
int | ix_timer_restart (ix_timer_t *pt, ix_event_t *pev, ix_timer_type_e type, ix_timer_val_t *pitv) |
int | ix_timer_id_free (unsigned long id) |
Timers are implemented by the timeout mechanism of the central select() call. During creation you can relate an event to a timer, which is fired when the timer elapse. You can choose between absolute timer, periodic timer, normal timer and one-shot timer, see ix_timer_new(), ix_timer_restart(), ... and ix_timer_val_init()
enum ix_timer_type_e |
void ix_get_timenow | ( | struct timeval * | ptv | ) |
Get actual time
ptv,: | pointer to store actual time |
struct timeval ix_timer_add | ( | struct timeval * | pt1, | |
struct timeval * | pt2 | |||
) |
Adds two timeval structures
pt1 | 1st summand | |
pt2 | 2nd summand |
int ix_timer_cancel | ( | ix_timer_t * | pt | ) |
cancel timer (not free), i.e. event will not be trigger. The timer can be used again with ix_timer_restart().
pt | handle of timer |
int ix_timer_free | ( | ix_timer_t * | pt | ) |
cancel and frees timer
pt | handle of timer object |
int ix_timer_id_free | ( | unsigned long | id | ) |
cancel and frees all timer with userid id if id == 0 all timers are cancelled and freed
it | timer id |
ix_timer_t* ix_timer_new | ( | ix_event_t * | pev, | |
ix_timer_type_e | type, | |||
unsigned long | userid, | |||
void(*)(void *parg) | cb, | |||
void * | parg, | |||
ix_timer_val_t * | pitv | |||
) |
constructor, creates new timer
pev | handle of event which is triggered when timer fires | |
type | type of timer s.above | |
userid | some id which is used in ix_timer_id_free() to cancel and free timer | |
cb | if supplied the callback is called when timer expires | |
parg | argument for the callback | |
pitv | time structure to supply sec and micro-sec for time to ellapse as absolute, delta, or startdelta and period time (minimal value is 1000 usec i.e. 1 milli sec) |
int ix_timer_restart | ( | ix_timer_t * | pt, | |
ix_event_t * | pev, | |||
ix_timer_type_e | type, | |||
ix_timer_val_t * | pitv | |||
) |
restart timer after or before it fired with new features
pt | handle of timer | |
pev | handle of event to trigger | |
type | type of timer | |
pitv | the time values |
int ix_timer_val_init | ( | ix_timer_val_t * | ptv, | |
int | v_sec, | |||
int | v_usec, | |||
int | i_sec, | |||
int | i_usec | |||
) |
utility function to initialize timer value
v_sec,: | second of absolute or normal timer, or start sec of periodic timer | |
v_usec,: | micro-second of absolute or normal timer, or start msec of periodic timer | |
i_sec,: | second of periodic timer | |
i_usec,: | micro-second of periodic timer |