2 Unix SMB/CIFS implementation.
4 generalised event loop handling
8 Copyright (C) Stefan Metzmacher 2005
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 int (*context_init)(struct tevent_context *ev);
28 /* fd_event functions */
29 struct tevent_fd *(*add_fd)(struct tevent_context *ev,
31 int fd, uint16_t flags,
32 tevent_fd_handler_t handler,
34 const char *handler_name,
35 const char *location);
36 uint16_t (*get_fd_flags)(struct tevent_fd *fde);
37 void (*set_fd_flags)(struct tevent_fd *fde, uint16_t flags);
39 /* timed_event functions */
40 struct tevent_timer *(*add_timer)(struct tevent_context *ev,
42 struct timeval next_event,
43 tevent_timer_handler_t handler,
45 const char *handler_name,
46 const char *location);
47 /* disk aio event functions */
48 struct tevent_aio *(*add_aio)(struct tevent_context *ev,
51 tevent_aio_handler_t handler,
53 const char *handler_name,
54 const char *location);
55 /* signal functions */
56 struct tevent_signal *(*add_signal)(struct tevent_context *ev,
58 int signum, int sa_flags,
59 tevent_signal_handler_t handler,
61 const char *handler_name,
62 const char *location);
65 int (*loop_once)(struct tevent_context *ev);
66 int (*loop_wait)(struct tevent_context *ev);
70 struct tevent_fd *prev, *next;
71 struct tevent_context *event_ctx;
73 uint16_t flags; /* see EVENT_FD_* flags */
74 tevent_fd_handler_t handler;
75 /* this is private for the specific handler */
77 /* this is for debugging only! */
78 const char *handler_name;
80 /* this is private for the events_ops implementation */
81 uint16_t additional_flags;
82 void *additional_data;
86 struct tevent_timer *prev, *next;
87 struct tevent_context *event_ctx;
88 struct timeval next_event;
89 tevent_timer_handler_t handler;
90 /* this is private for the specific handler */
92 /* this is for debugging only! */
93 const char *handler_name;
95 /* this is private for the events_ops implementation */
96 void *additional_data;
99 struct tevent_signal {
100 struct tevent_signal *prev, *next;
101 struct tevent_context *event_ctx;
104 tevent_signal_handler_t handler;
105 /* this is private for the specific handler */
107 /* this is for debugging only! */
108 const char *handler_name;
109 const char *location;
110 /* this is private for the events_ops implementation */
111 void *additional_data;
114 struct tevent_debug_ops {
115 void (*debug)(void *context, enum tevent_debug_level level,
116 const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0);
120 void tevent_debug(struct tevent_context *ev, enum tevent_debug_level level,
121 const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
123 /* aio event is private to the aio backend */
126 struct tevent_context {
127 /* the specific events implementation */
128 const struct tevent_ops *ops;
130 /* list of timed events - used by common code */
131 struct tevent_timer *timer_events;
133 /* this is private for the events_ops implementation */
134 void *additional_data;
136 /* number of signal event handlers */
137 int num_signal_handlers;
139 /* pipe hack used with signal handlers */
140 struct tevent_fd *pipe_fde;
142 /* debugging operations */
143 struct tevent_debug_ops debug_ops;
147 bool tevent_register_backend(const char *name, const struct tevent_ops *ops);
149 bool ev_timeval_is_zero(const struct timeval *tv);
150 struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev,
152 struct timeval next_event,
153 tevent_timer_handler_t handler,
155 const char *handler_name,
156 const char *location);
157 struct timeval tevent_common_loop_timer_delay(struct tevent_context *);
159 struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,
163 tevent_signal_handler_t handler,
165 const char *handler_name,
166 const char *location);
167 int tevent_common_check_signal(struct tevent_context *ev);
169 bool tevent_standard_init(void);
170 bool tevent_select_init(void);
172 bool tevent_epoll_init(void);
174 #ifdef HAVE_LINUX_AIO
175 bool tevent_aio_init(void);