OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2000-2004 Niels Provos <provos@citi.umich.edu> | |
3 * All rights reserved. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions | |
7 * are met: | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * 3. The name of the author may not be used to endorse or promote products | |
14 * derived from this software without specific prior written permission. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 #ifndef _EVENT_INTERNAL_H_ | |
28 #define _EVENT_INTERNAL_H_ | |
29 | |
30 #ifdef __cplusplus | |
31 extern "C" { | |
32 #endif | |
33 | |
34 #include "config.h" | |
35 #include "min_heap.h" | |
36 #include "evsignal.h" | |
37 | |
38 struct eventop { | |
39 const char *name; | |
40 void *(*init)(struct event_base *); | |
41 int (*add)(void *, struct event *); | |
42 int (*del)(void *, struct event *); | |
43 int (*dispatch)(struct event_base *, void *, struct timeval *); | |
44 void (*dealloc)(struct event_base *, void *); | |
45 /* set if we need to reinitialize the event base */ | |
46 int need_reinit; | |
47 }; | |
48 | |
49 struct event_base { | |
50 const struct eventop *evsel; | |
51 void *evbase; | |
52 int event_count; /* counts number of total events */ | |
53 int event_count_active; /* counts number of active events */ | |
54 | |
55 int event_gotterm; /* Set to terminate loop */ | |
56 int event_break; /* Set to terminate loop immediately */ | |
57 | |
58 /* active event management */ | |
59 struct event_list **activequeues; | |
60 int nactivequeues; | |
61 | |
62 /* signal handling info */ | |
63 struct evsignal_info sig; | |
64 | |
65 struct event_list eventqueue; | |
66 struct timeval event_tv; | |
67 | |
68 struct min_heap timeheap; | |
69 | |
70 struct timeval tv_cache; | |
71 }; | |
72 | |
73 /* Internal use only: Functions that might be missing from <sys/queue.h> */ | |
74 #ifndef HAVE_TAILQFOREACH | |
75 #define TAILQ_FIRST(head) ((head)->tqh_first) | |
76 #define TAILQ_END(head) NULL | |
77 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) | |
78 #define TAILQ_FOREACH(var, head, field) \ | |
79 for((var) = TAILQ_FIRST(head); \ | |
80 (var) != TAILQ_END(head); \ | |
81 (var) = TAILQ_NEXT(var, field)) | |
82 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ | |
83 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ | |
84 (elm)->field.tqe_next = (listelm); \ | |
85 *(listelm)->field.tqe_prev = (elm); \ | |
86 (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ | |
87 } while (0) | |
88 #endif /* TAILQ_FOREACH */ | |
89 | |
90 int _evsignal_set_handler(struct event_base *base, int evsignal, | |
91 void (*fn)(int)); | |
92 int _evsignal_restore_handler(struct event_base *base, int evsignal); | |
93 | |
94 /* defined in evutil.c */ | |
95 const char *evutil_getenv(const char *varname); | |
96 | |
97 #ifdef __cplusplus | |
98 } | |
99 #endif | |
100 | |
101 #endif /* _EVENT_INTERNAL_H_ */ | |
OLD | NEW |