]> git.decadent.org.uk Git - ion3.git/blob - libmainloop/signal.h
7e8682e33c7b2d455e9756c6102b3a37a19ac6de
[ion3.git] / libmainloop / signal.h
1 /*
2  * ion/mainloop/signal.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  *
6  * Ion is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  */
11
12 #ifndef ION_LIBMAINLOOP_SIGNAL_H
13 #define ION_LIBMAINLOOP_SIGNAL_H
14
15 #include <sys/time.h>
16 #include <sys/signal.h>
17 #include <signal.h>
18 #include <time.h>
19 #include <unistd.h>
20
21 #include <libtu/obj.h>
22 #include <libtu/types.h>
23 #include <libextl/extl.h>
24
25 #include "hooks.h"
26
27 INTRCLASS(WTimer);
28
29 typedef void WTimerHandler(WTimer *timer, Obj *obj);
30
31
32 DECLCLASS(WTimer){
33     Obj obj;
34     struct timeval when;
35     WTimer *next;
36     WTimerHandler *handler;
37     Watch objwatch;
38     ExtlFn extl_handler;
39 };
40
41 extern bool timer_init(WTimer *timer);
42 extern void timer_deinit(WTimer *timer);
43
44 extern WTimer *create_timer();
45 extern WTimer *create_timer_extl_owned();
46
47 extern void timer_set(WTimer *timer, uint msecs, WTimerHandler *handler,
48                       Obj *obj);
49 extern void timer_set_extl(WTimer *timer, uint msecs, ExtlFn fn);
50
51 extern void timer_reset(WTimer *timer);
52 extern bool timer_is_set(WTimer *timer);
53
54 extern bool mainloop_check_signals();
55 extern void mainloop_trap_signals(const sigset_t *set);
56
57 extern WHook *mainloop_sigchld_hook;
58 extern WHook *mainloop_sigusr2_hook;
59
60 #endif /* ION_LIBMAINLOOP_SIGNAL_H */