|
libuev
|
Monotonic timers, Linux timerfd(2) More...

Functions | |
| int | uev_timer_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int timeout, int period) |
| Create and start a timer watcher. More... | |
| int | uev_timer_set (uev_t *w, int timeout, int period) |
| Reset a timer. More... | |
| int | uev_timer_start (uev_t *w) |
| Start a stopped timer watcher. More... | |
| int | uev_timer_stop (uev_t *w) |
| Stop and unregister a timer watcher. More... | |
Monotonic timers, Linux timerfd(2)
| int uev_timer_init | ( | uev_ctx_t * | ctx, |
| uev_t * | w, | ||
| uev_cb_t * | cb, | ||
| void * | arg, | ||
| int | timeout, | ||
| int | period | ||
| ) |
Create and start a timer watcher.
| ctx | A valid libuEv context |
| w | Pointer to an uev_t watcher |
| cb | Callback function |
| arg | Optional callback argument |
| timeout | Timeout in milliseconds before cb is called |
| period | For periodic timers this is the period time that timeout is reset to |
This function creates, and optionally starts, a timer watcher. There are two types of timers: one-shot and periodic.
One-shot timers only use timeout, period is zero.
Periodic timers can either start their life disabled, with timeout set to zero, or with the same value as period.
When the timeout expires, for either of the two types, cb is called, with the optional arg argument. A one-shot timer ends its life there, while a periodic task's timeout is reset to the period and restarted.
A timer is automatically started if the event loop is already running, otherwise it is kept on hold until triggered by calling uev_run().
errno set on error. | int uev_timer_set | ( | uev_t * | w, |
| int | timeout, | ||
| int | period | ||
| ) |
Reset a timer.
| w | Watcher to reset |
| timeout | Timeout in milliseconds before cb is called, zero disarms timer |
| period | For periodic timers this is the period time that timeout is reset to |
Note, the timeout value must be non-zero. Setting it to zero disarms the timer. This is the behavior of the underlying Linux function timerfd_settimer(2)
errno set on error. | int uev_timer_start | ( | uev_t * | w | ) |
Start a stopped timer watcher.
| w | Watcher to start (again) |
errno set on error. | int uev_timer_stop | ( | uev_t * | w | ) |
Stop and unregister a timer watcher.
| w | Watcher to stop |
errno set on error.
1.8.13