libcortex
Event loop library following a "batteries included" approach
Loading...
Searching...
No Matches
timer.h
1#ifndef _CRTX_TIMER_H
2#define _CRTX_TIMER_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/*
9 * Mario Kicherer (dev@kicherer.org) 2016
10 *
11 */
12
13#include "core.h"
14
15#define CRTX_EVT_TIMER "cortex.timer"
16
17// for settime_flags
18// #include <sys/timerfd.h>
19
21 struct crtx_listener_base base;
22
23 int fd;
24 crtx_handle_task_t direct_callback;
25 void *direct_userdata;
26
27 int clockid;
28 struct itimerspec newtimer;
29 int settime_flags;
30};
31
33 struct crtx_timer_listener tlstnr;
34
35 void (*oneshot_callback)(void *data);
36 void *oneshot_data;
37};
38
40 struct crtx_timer_listener timer_lstnr;
41
42 struct crtx_listener_base *lstnr;
43
44 unsigned int seconds;
45};
46
47struct crtx_timer_retry_listener *crtx_timer_retry_listener(struct crtx_listener_base *lstnr, unsigned int seconds);
48void crtx_timer_retry_listener_free(struct crtx_timer_retry_listener *retry_lstnr);
49int crtx_timer_get_listener(struct crtx_timer_listener *tlist,
50 time_t offset_sec,
51 long offset_nsec,
52 time_t int_sec,
53 long int_nsec
54 );
55
56int crtx_timer_rearm(struct crtx_timer_listener *tlist,
57 time_t offset_sec,
58 long offset_nsec,
59 time_t int_sec,
60 long int_nsec);
61int crtx_timer_oneshot(time_t offset_sec,
62 long offset_nsec,
63 int clockid,
64 void (*callback)(void *),
65 void *callback_userdata
66 );
67int crtx_timer_retry_listener_os(struct crtx_listener_base *lstnr, unsigned int seconds, unsigned long nanoseconds);
68
69struct crtx_listener_base *crtx_setup_timer_listener(void *options);
70CRTX_DECLARE_ALLOC_FUNCTION(timer)
71
72void crtx_timer_init();
73void crtx_timer_finish();
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif
The core definitions of libcortex.
base structure of a listener
Definition core.h:186
Definition timer.h:20
Definition timer.h:32
Definition timer.h:39