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 2 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, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 int (*context_init)(struct event_context *ev);
29 /* fd_event functions */
30 struct fd_event *(*add_fd)(struct event_context *ev,
32 int fd, uint16_t flags,
33 event_fd_handler_t handler,
35 uint16_t (*get_fd_flags)(struct fd_event *fde);
36 void (*set_fd_flags)(struct fd_event *fde, uint16_t flags);
38 /* timed_event functions */
39 struct timed_event *(*add_timed)(struct event_context *ev,
41 struct timeval next_event,
42 event_timed_handler_t handler,
44 /* disk aio event functions */
45 struct aio_event *(*add_aio)(struct event_context *ev,
48 event_aio_handler_t handler,
50 /* signal functions */
51 struct signal_event *(*add_signal)(struct event_context *ev,
53 int signum, int sa_flags,
54 event_signal_handler_t handler,
58 int (*loop_once)(struct event_context *ev);
59 int (*loop_wait)(struct event_context *ev);
63 struct fd_event *prev, *next;
64 struct event_context *event_ctx;
66 uint16_t flags; /* see EVENT_FD_* flags */
67 event_fd_handler_t handler;
68 /* this is private for the specific handler */
70 /* this is private for the events_ops implementation */
71 uint16_t additional_flags;
72 void *additional_data;
76 struct timed_event *prev, *next;
77 struct event_context *event_ctx;
78 struct timeval next_event;
79 event_timed_handler_t handler;
80 /* this is private for the specific handler */
82 /* this is private for the events_ops implementation */
83 void *additional_data;
87 struct signal_event *prev, *next;
88 struct event_context *event_ctx;
89 event_signal_handler_t handler;
95 /* aio event is private to the aio backend */
98 struct event_context {
99 /* the specific events implementation */
100 const struct event_ops *ops;
102 /* list of timed events - used by common code */
103 struct timed_event *timed_events;
105 /* this is private for the events_ops implementation */
106 void *additional_data;
108 /* number of signal event handlers */
109 int num_signal_handlers;
111 /* pipe hack used with signal handlers */
112 struct fd_event *pipe_fde;
116 bool event_register_backend(const char *name, const struct event_ops *ops);
118 struct timed_event *common_event_add_timed(struct event_context *, TALLOC_CTX *,
119 struct timeval, event_timed_handler_t, void *);
120 struct timeval common_event_loop_timer_delay(struct event_context *);
122 struct signal_event *common_event_add_signal(struct event_context *ev,
126 event_signal_handler_t handler,
128 int common_event_check_signal(struct event_context *ev);