At/Cron like timers.
More...
#include <errno.h>
#include <string.h>
#include <sys/timerfd.h>
#include <unistd.h>
#include "uev.h"
|
#define | TFD_TIMER_CANCEL_ON_SET (1 << 1) |
|
#define | TFD_SETTIME_FLAGS (TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET) |
|
◆ uev_cron_init()
Create and start an at/cron job watcher.
- Parameters
-
ctx | A valid libuEv context |
w | Pointer to an uev_t watcher |
cb | Callback function for cron job |
arg | Optional callback argument |
when | First point in time to call cb |
interval | For an at job this is zero, for cron the offset interval |
For at jobs set interval
to zero and only use when
. For cron jobs, set interval
to the offset. E.g., if the job should run every five minutes set the tm_min
of struct tm to five.
Use mktime() to create the time_t arguments. The special value zero may be used for when
to denote 'now', where 'now' is when the event loop is started. You can also treat time_t simply as a signed integer. E.g., set interval
to 3600 to create a cron job that runs every hour.
- Returns
- POSIX OK(0) or non-zero with
errno
set on error.
◆ uev_cron_set()
int uev_cron_set |
( |
uev_t * |
w, |
|
|
time_t |
when, |
|
|
time_t |
interval |
|
) |
| |
Reset an at/cron job watcher.
- Parameters
-
w | Watcher to reset |
when | First point in time to call cb |
interval | For an at job this is zero, for cron the offset interval |
- Returns
- POSIX OK(0) or non-zero with
errno
set on error.
◆ uev_cron_start()
int uev_cron_start |
( |
uev_t * |
w | ) |
|
Start a stopped at/cron job watcher.
- Parameters
-
w | Watcher to start (again) |
- Returns
- POSIX OK(0) or non-zero with
errno
set on error.
◆ uev_cron_stop()
int uev_cron_stop |
( |
uev_t * |
w | ) |
|
Stop and unregister an at/cron job watcher.
- Parameters
-
- Returns
- POSIX OK(0) or non-zero with
errno
set on error.