]> git.decadent.org.uk Git - ion3.git/blob - libmainloop/signal.h
bd93fb2aeea8c96bb2eb2949cd86209c793339c3
[ion3.git] / libmainloop / signal.h
1 /*
2  * ion/mainloop/signal.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2008. 
5  *
6  * See the included file LICENSE for details.
7  */
8
9 #ifndef ION_LIBMAINLOOP_SIGNAL_H
10 #define ION_LIBMAINLOOP_SIGNAL_H
11
12 #include <sys/time.h>
13 #include <sys/signal.h>
14 #include <signal.h>
15 #include <time.h>
16 #include <unistd.h>
17
18 #include <libtu/obj.h>
19 #include <libtu/types.h>
20 #include <libextl/extl.h>
21
22 #include "hooks.h"
23
24 INTRCLASS(WTimer);
25
26 typedef void WTimerHandler(WTimer *timer, Obj *obj);
27
28
29 DECLCLASS(WTimer){
30     Obj obj;
31     struct timeval when;
32     WTimer *next;
33     WTimerHandler *handler;
34     Watch objwatch;
35     ExtlFn extl_handler;
36 };
37
38 extern bool timer_init(WTimer *timer);
39 extern void timer_deinit(WTimer *timer);
40
41 extern WTimer *create_timer();
42 extern WTimer *create_timer_extl_owned();
43
44 extern void timer_set(WTimer *timer, uint msecs, WTimerHandler *handler,
45                       Obj *obj);
46 extern void timer_set_extl(WTimer *timer, uint msecs, ExtlFn fn);
47
48 extern void timer_reset(WTimer *timer);
49 extern bool timer_is_set(WTimer *timer);
50
51 extern bool mainloop_check_signals();
52 extern void mainloop_trap_signals(const sigset_t *set);
53 extern void mainloop_block_signals(sigset_t *oldmask);
54 extern bool mainloop_unhandled_signals();
55 extern bool libmainloop_get_timeout(struct timeval *tv);
56
57 extern WHook *mainloop_sigchld_hook;
58 extern WHook *mainloop_sigusr2_hook;
59
60 /* Returns monotonic time if possible */
61 extern int mainloop_gettime(struct timeval *val);
62
63 #endif /* ION_LIBMAINLOOP_SIGNAL_H */