libuev 2.4.1
cron.c File Reference
#include <errno.h>
#include <string.h>
#include <sys/timerfd.h>
#include <unistd.h>
#include "uev.h"

Go to the source code of this file.

Macros

#define TFD_TIMER_CANCEL_ON_SET   (1 << 1)
 
#define TFD_SETTIME_FLAGS   (TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET)
 

Functions

int uev_cron_init (uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, time_t when, time_t interval)
 
int uev_cron_set (uev_t *w, time_t when, time_t interval)
 
int uev_cron_start (uev_t *w)
 
int uev_cron_stop (uev_t *w)
 

Detailed Description

At/Cron like timers.

Definition in file cron.c.

Macro Definition Documentation

◆ TFD_SETTIME_FLAGS

#define TFD_SETTIME_FLAGS   (TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET)

Definition at line 37 of file cron.c.

◆ TFD_TIMER_CANCEL_ON_SET

#define TFD_TIMER_CANCEL_ON_SET   (1 << 1)

Definition at line 34 of file cron.c.

Function Documentation

◆ uev_cron_init()

int uev_cron_init ( uev_ctx_t * ctx,
uev_t * w,
uev_cb_t * cb,
void * arg,
time_t when,
time_t interval )

Create and start an at/cron job watcher

Parameters
ctxA valid libuEv context
wPointer to an uev_t watcher
cbCallback function for cron job
argOptional callback argument
whenFirst point in time to call cb
intervalFor 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.

Definition at line 66 of file cron.c.

◆ uev_cron_set()

int uev_cron_set ( uev_t * w,
time_t when,
time_t interval )

Reset an at/cron job watcher

Parameters
wWatcher to reset
whenFirst point in time to call cb
intervalFor an at job this is zero, for cron the offset interval
Returns
POSIX OK(0) or non-zero with errno set on error.

Definition at line 100 of file cron.c.

◆ uev_cron_start()

int uev_cron_start ( uev_t * w)

Start a stopped at/cron job watcher

Parameters
wWatcher to start (again)
Returns
POSIX OK(0) or non-zero with errno set on error.

Definition at line 145 of file cron.c.

◆ uev_cron_stop()

int uev_cron_stop ( uev_t * w)

Stop and unregister an at/cron job watcher

Parameters
wWatcher to stop
Returns
POSIX OK(0) or non-zero with errno set on error.

Definition at line 156 of file cron.c.