1 /* A specialized Reactor.
2 * - by Richard W.M. Jones <rich@annexia.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * $Id: pthr_reactor.h,v 1.3 2002/08/21 10:42:20 rich Exp $
21 #ifndef PTHR_REACTOR_H
22 #define PTHR_REACTOR_H
28 /* A reactor handle. */
29 struct reactor_handle;
30 typedef int reactor_handle; /* These are offsets into a private array
31 * of struct reactor_handle.
36 typedef struct reactor_timer *reactor_timer;
38 /* Pre-poll handlers. */
39 struct reactor_prepoll;
40 typedef struct reactor_prepoll *reactor_prepoll;
42 /* Reactor operations. */
43 #define REACTOR_READ POLLIN
44 #define REACTOR_WRITE POLLOUT
46 /* Reactor time types. */
47 typedef unsigned long long reactor_time_t;
48 typedef signed long long reactor_timediff_t;
50 /* Reactor time in milliseconds from Unix epoch. */
51 extern reactor_time_t reactor_time;
53 /* Reactor functions. */
54 extern reactor_handle reactor_register (int socket, int operations,
55 void (*fn) (int socket, int events,
58 extern void reactor_unregister (reactor_handle handle);
59 extern reactor_timer reactor_set_timer (pool, int timeout,
60 void (*fn) (void *data),
62 extern void reactor_unset_timer_early (reactor_timer timer);
63 extern reactor_prepoll reactor_register_prepoll (pool, void (*fn) (void *data),
65 extern void reactor_unregister_prepoll (reactor_prepoll handle);
66 extern void reactor_invoke (void);
68 #endif /* PTHR_REACTOR_H */