root / lab4 / .minix-src / include / event2 / event_compat.h @ 14
History | View | Annotate | Download (7.36 KB)
1 |
/* $NetBSD: event_compat.h,v 1.1.1.2 2015/01/29 06:38:27 spz Exp $ */
|
---|---|
2 |
/* $NetBSD: event_compat.h,v 1.1.1.2 2015/01/29 06:38:27 spz Exp $ */
|
3 |
/*
|
4 |
* Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
|
5 |
* Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
|
6 |
*
|
7 |
* Redistribution and use in source and binary forms, with or without
|
8 |
* modification, are permitted provided that the following conditions
|
9 |
* are met:
|
10 |
* 1. Redistributions of source code must retain the above copyright
|
11 |
* notice, this list of conditions and the following disclaimer.
|
12 |
* 2. Redistributions in binary form must reproduce the above copyright
|
13 |
* notice, this list of conditions and the following disclaimer in the
|
14 |
* documentation and/or other materials provided with the distribution.
|
15 |
* 3. The name of the author may not be used to endorse or promote products
|
16 |
* derived from this software without specific prior written permission.
|
17 |
*
|
18 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
19 |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
20 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
21 |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
22 |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
23 |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
24 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
25 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
27 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28 |
*/
|
29 |
#ifndef _EVENT2_EVENT_COMPAT_H_
|
30 |
#define _EVENT2_EVENT_COMPAT_H_
|
31 |
|
32 |
/** @file event2/event_compat.h
|
33 |
|
34 |
Potentially non-threadsafe versions of the functions in event.h: provided
|
35 |
only for backwards compatibility.
|
36 |
|
37 |
In the oldest versions of Libevent, event_base was not a first-class
|
38 |
structure. Instead, there was a single event base that every function
|
39 |
manipulated. Later, when separate event bases were added, the old functions
|
40 |
that didn't take an event_base argument needed to work by manipulating the
|
41 |
"current" event base. This could lead to thread-safety issues, and obscure,
|
42 |
hard-to-diagnose bugs.
|
43 |
|
44 |
@deprecated All functions in this file are by definition deprecated.
|
45 |
*/
|
46 |
|
47 |
#ifdef __cplusplus
|
48 |
extern "C" { |
49 |
#endif
|
50 |
|
51 |
#include <event2/event-config.h> |
52 |
#ifdef _EVENT_HAVE_SYS_TYPES_H
|
53 |
#include <sys/types.h> |
54 |
#endif
|
55 |
#ifdef _EVENT_HAVE_SYS_TIME_H
|
56 |
#include <sys/time.h> |
57 |
#endif
|
58 |
|
59 |
/* For int types. */
|
60 |
#include <event2/util.h> |
61 |
|
62 |
/**
|
63 |
Initialize the event API.
|
64 |
|
65 |
The event API needs to be initialized with event_init() before it can be
|
66 |
used. Sets the global current base that gets used for events that have no
|
67 |
base associated with them.
|
68 |
|
69 |
@deprecated This function is deprecated because it replaces the "current"
|
70 |
event_base, and is totally unsafe for multithreaded use. The replacement
|
71 |
is event_base_new().
|
72 |
|
73 |
@see event_base_set(), event_base_new()
|
74 |
*/
|
75 |
struct event_base *event_init(void); |
76 |
|
77 |
/**
|
78 |
Loop to process events.
|
79 |
|
80 |
Like event_base_dispatch(), but uses the "current" base.
|
81 |
|
82 |
@deprecated This function is deprecated because it is easily confused by
|
83 |
multiple calls to event_init(), and because it is not safe for
|
84 |
multithreaded use. The replacement is event_base_dispatch().
|
85 |
|
86 |
@see event_base_dispatch(), event_init()
|
87 |
*/
|
88 |
int event_dispatch(void); |
89 |
|
90 |
/**
|
91 |
Handle events.
|
92 |
|
93 |
This function behaves like event_base_loop(), but uses the "current" base
|
94 |
|
95 |
@deprecated This function is deprecated because it uses the event base from
|
96 |
the last call to event_init, and is therefore not safe for multithreaded
|
97 |
use. The replacement is event_base_loop().
|
98 |
|
99 |
@see event_base_loop(), event_init()
|
100 |
*/
|
101 |
int event_loop(int); |
102 |
|
103 |
|
104 |
/**
|
105 |
Exit the event loop after the specified time.
|
106 |
|
107 |
This function behaves like event_base_loopexit(), except that it uses the
|
108 |
"current" base.
|
109 |
|
110 |
@deprecated This function is deprecated because it uses the event base from
|
111 |
the last call to event_init, and is therefore not safe for multithreaded
|
112 |
use. The replacement is event_base_loopexit().
|
113 |
|
114 |
@see event_init, event_base_loopexit()
|
115 |
*/
|
116 |
int event_loopexit(const struct timeval *); |
117 |
|
118 |
|
119 |
/**
|
120 |
Abort the active event_loop() immediately.
|
121 |
|
122 |
This function behaves like event_base_loopbreakt(), except that it uses the
|
123 |
"current" base.
|
124 |
|
125 |
@deprecated This function is deprecated because it uses the event base from
|
126 |
the last call to event_init, and is therefore not safe for multithreaded
|
127 |
use. The replacement is event_base_loopbreak().
|
128 |
|
129 |
@see event_base_loopbreak(), event_init()
|
130 |
*/
|
131 |
int event_loopbreak(void); |
132 |
|
133 |
/**
|
134 |
Schedule a one-time event to occur.
|
135 |
|
136 |
@deprecated This function is obsolete, and has been replaced by
|
137 |
event_base_once(). Its use is deprecated because it relies on the
|
138 |
"current" base configured by event_init().
|
139 |
|
140 |
@see event_base_once()
|
141 |
*/
|
142 |
int event_once(evutil_socket_t , short, |
143 |
void (*)(evutil_socket_t, short, void *), void *, const struct timeval *); |
144 |
|
145 |
|
146 |
/**
|
147 |
Get the kernel event notification mechanism used by Libevent.
|
148 |
|
149 |
@deprecated This function is obsolete, and has been replaced by
|
150 |
event_base_get_method(). Its use is deprecated because it relies on the
|
151 |
"current" base configured by event_init().
|
152 |
|
153 |
@see event_base_get_method()
|
154 |
*/
|
155 |
const char *event_get_method(void); |
156 |
|
157 |
|
158 |
/**
|
159 |
Set the number of different event priorities.
|
160 |
|
161 |
@deprecated This function is deprecated because it is easily confused by
|
162 |
multiple calls to event_init(), and because it is not safe for
|
163 |
multithreaded use. The replacement is event_base_priority_init().
|
164 |
|
165 |
@see event_base_priority_init()
|
166 |
*/
|
167 |
int event_priority_init(int); |
168 |
|
169 |
/**
|
170 |
Prepare an event structure to be added.
|
171 |
|
172 |
@deprecated event_set() is not recommended for new code, because it requires
|
173 |
a subsequent call to event_base_set() to be safe under most circumstances.
|
174 |
Use event_assign() or event_new() instead.
|
175 |
*/
|
176 |
void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *); |
177 |
|
178 |
#define evtimer_set(ev, cb, arg) event_set((ev), -1, 0, (cb), (arg)) |
179 |
#define evsignal_set(ev, x, cb, arg) \
|
180 |
event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg)) |
181 |
|
182 |
|
183 |
/**
|
184 |
@name timeout_* macros
|
185 |
|
186 |
@deprecated These macros are deprecated because their naming is inconsistent
|
187 |
with the rest of Libevent. Use the evtimer_* macros instead.
|
188 |
@{
|
189 |
*/
|
190 |
#define timeout_add(ev, tv) event_add((ev), (tv))
|
191 |
#define timeout_set(ev, cb, arg) event_set((ev), -1, 0, (cb), (arg)) |
192 |
#define timeout_del(ev) event_del(ev)
|
193 |
#define timeout_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv))
|
194 |
#define timeout_initialized(ev) event_initialized(ev)
|
195 |
/**@}*/
|
196 |
|
197 |
/**
|
198 |
@name signal_* macros
|
199 |
|
200 |
@deprecated These macros are deprecated because their naming is inconsistent
|
201 |
with the rest of Libevent. Use the evsignal_* macros instead.
|
202 |
@{
|
203 |
*/
|
204 |
#define signal_add(ev, tv) event_add((ev), (tv))
|
205 |
#define signal_set(ev, x, cb, arg) \
|
206 |
event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg)) |
207 |
#define signal_del(ev) event_del(ev)
|
208 |
#define signal_pending(ev, tv) event_pending((ev), EV_SIGNAL, (tv))
|
209 |
#define signal_initialized(ev) event_initialized(ev)
|
210 |
/**@}*/
|
211 |
|
212 |
#ifndef EVENT_FD
|
213 |
/* These macros are obsolete; use event_get_fd and event_get_signal instead. */
|
214 |
#define EVENT_FD(ev) ((int)event_get_fd(ev)) |
215 |
#define EVENT_SIGNAL(ev) event_get_signal(ev)
|
216 |
#endif
|
217 |
|
218 |
#ifdef __cplusplus
|
219 |
} |
220 |
#endif
|
221 |
|
222 |
#endif /* _EVENT2_EVENT_COMPAT_H_ */ |