Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 484 lines (381 sloc) 16.419 kb
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
1 include::license.txt[]
2
3 :language: C
4
5 Creating an event_base
6 ----------------------
7
8 Before you can use any interesting Libevent function, you need to allocate
9 one or more event_base structures. Each event_base structure holds a set of
85b35f18 »
2009-04-24 Initial editing pass from Susan.
10 events and can poll to determine which events are active.
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
11
12 If an event_base is set up to use locking, it is safe to access it between
13 multiple threads. Its loop can only be run in a single thread, however. If
14 you want to have multiple threads polling for IO, you need to have an
15 event_base for each thread.
16
17 TIP: [A future version of Libevent may have support for event_bases that run
18 events across multiple threads.]
19
20 Each event_base has a "method", or a backend that it uses to determine which
21 events are ready. The recognized methods are:
22
23 - select
24 - poll
25 - epoll
26 - kqueue
27 - devpoll
28 - evport
29 - win32
30
31 The user can disable specific backends with environment variables. If you
32 want to turn off the kqueue backend, set the EVENT_NOKQUEUE environment
33 variable, and so on. If you want to turn off backends from within the
34 program, see notes on event_config_avoid_method() below.
35
36 Setting up a default event_base
37 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38
39 The event_base_new() function allocates and returns a new event base with
85b35f18 »
2009-04-24 Initial editing pass from Susan.
40 the default settings. It examines the environment variables and returns
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
41 a pointer to a new event_base. If there is an error, it returns NULL.
42
43 When choosing among methods, it picks the fastest method that the OS
44 supports.
45
46 .Interface
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
47 [code,C]
48 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
49 struct event_base *event_base_new(void);
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
50 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
51
52 For most programs, this is all you need.
53
54 The event_base_new() function is declared in <event2/event.h>. It first
55 appeared in Libevent 1.4.3.
56
57 Setting up a complicated event_base
58 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59
60 If you want more control over what kind of event_base you get, you need to
61 use an event_config. An event_config is an opaque structure that holds
62 information about your preferences for an event_base. When you want an
63 event_base, you pass the event_config to event_base_new_with_config().
64
65 .Interface
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
66 [code,C]
67 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
68 struct event_config *event_config_new(void);
0b1e73a0 »
2010-02-02 Note a few functions that just got const-ized
69 struct event_base *event_base_new_with_config(const struct event_config *cfg);
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
70 void event_config_free(struct event_config *cfg);
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
71 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
72
73 To allocate an event_base with these functions, you call event_config_new()
74 to allocate a new event_config. Then, you call other functions on the
75 event_config to tell it about your needs. Finally, you call
76 event_base_new_with_config() to get a new event_base. When you are done,
77 you can free the event_config with event_config_free().
78
79 .Interface
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
80 [code,C]
81 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
82 int event_config_avoid_method(struct event_config *cfg, const char *method);
83
84 enum event_method_feature {
85 EV_FEATURE_ET = 0x01,
86 EV_FEATURE_O1 = 0x02,
87 EV_FEATURE_FDS = 0x04,
88 };
89 int event_config_require_features(struct event_config *cfg,
90 enum event_method_feature feature);
91
92 enum event_base_config_flag {
fa74aaa3 »
2009-11-20 Revise sections up to Ref5 for 2.0.3-alpha.
93 EVENT_BASE_FLAG_NOLOCK = 0x01,
94 EVENT_BASE_FLAG_IGNORE_ENV = 0x02,
95 EVENT_BASE_FLAG_STARTUP_IOCP = 0x04,
96 EVENT_BASE_FLAG_NO_CACHE_TIME = 0x08,
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
97 };
98 int event_config_set_flag(struct event_config *cfg,
99 enum event_base_config_flag flag);
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
100 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
101
85b35f18 »
2009-04-24 Initial editing pass from Susan.
102 Calling event_config_avoid_method tells Libevent to avoid a specific
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
103 available backend by name. Calling event_config_require_feature() tells
104 Libevent not to use any backend that cannot supply all of a set of features.
fa74aaa3 »
2009-11-20 Revise sections up to Ref5 for 2.0.3-alpha.
105 Calling event_config_set_flag() tells Libevent to set one or more of
106 the run-time flags below when constructing the event base.
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
107
108 The recognized feature values for event_config_require_features are:
109
775ae0f7 »
2012-01-31 Typo and formatting fixes
110 EV_FEATURE_ET::
111 Requires a backend method that supports edge-triggered IO.
112
113 EV_FEATURE_O1::
114 Requires a backend method where adding or deleting a single
115 event, or having a single event become active, is an O(1) operation.
116
117 EV_FEATURE_FDS::
118 Requires a backend method that can support arbitrary file
119 descriptor types, and not just sockets.
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
120
121 The recognized option values for event_config_set_flag() are:
122
775ae0f7 »
2012-01-31 Typo and formatting fixes
123 EVENT_BASE_FLAG_NOLOCK::
124 Do not allocate locks for the event_base. Setting
125 this option may save a little time for locking and releasing the
7f38f320 »
2012-05-14 Make it more clear that NOLOCK means "I promise, no multithreading"
126 event_base, but will make it unsafe and nonfunctional to access it
127 from multiple threads.
775ae0f7 »
2012-01-31 Typo and formatting fixes
128
129 EVENT_BASE_FLAG_IGNORE_ENV::
130 Do not check the EVENT_* environment
131 variables when picking which backend method to use. Think hard before
132 using this flag: it can make it harder for users to debug the interactions
133 between your program and Libevent.
134
135 EVENT_BASE_FLAG_STARTUP_IOCP::
5b901b99 »
2012-06-15 Window->Windows
136 On Windows only, this flag makes Libevent
775ae0f7 »
2012-01-31 Typo and formatting fixes
137 enable any necessary IOCP dispatch logic on startup, rather than
138 on-demand.
139
140 EVENT_BASE_FLAG_NO_CACHE_TIME::
141 Instead of checking the current time every
142 time the event loop is ready to run timeout callbacks, check it after
143 every timeout callback. This can use more CPU than you necessarily
144 intended, so watch out!
145
146 EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST::
147 Tells Libevent that, if it decides to
148 use the epoll backend, it is safe to use the faster "changelist"-based
149 backend. The epoll-changelist backend can avoid needless system calls in
150 cases where the same fd has its status modified more than once between
151 calls to the backend's dispatch function, but it also trigger a kernel bug
152 that causes erroneous results if you give Libevent any fds cloned by
153 dup() or its variants. This flag has no effect if you use a backend
154 other than epoll. You can also turn on the epoll-changelist option by
5f9d78a2 »
2012-03-29 Fixed uSE_CHANGELIST, hOPE that's OK.
155 setting the EVENT_EPOLL_USE_CHANGELIST environment variable.
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
156
7ce95ded »
2012-04-18 Add documentation for some functions in 2.1.1-alpha
157 EVENT_BASE_FLAG_PRECISE_TIMER::
158 By default, Libevent tries to use the fastest available timing mechanism
159 that the operating system provides. If there is a slower timing
160 mechanism that provides more fine-grained timing precision, this
161 flag tells Libevent to use that timing mechanism instead. If the
162 operating system provides no such slower-but-more-precise mechanism,
163 this flag has no effect.
164
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
165 The above functions that manipulate an event_config all return 0 on success,
166 -1 on failure.
167
3f426202 »
2009-05-23 typo cleanup
168 NOTE: It is easy to set up an event_config that requires a backend that your
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
169 OS does not provide. For example, as of Libevent 2.0.1-alpha, there is no
170 O(1) backend for Windows, and no backend on Linux that provides both
171 EV_FEATURE_FDS and EV_FEATURE_O1. If you have made a configuration that
172 Libevent can't satisfy, event_base_new_with_config() will return NULL.
173
eaa82586 »
2010-09-09 Document new-in-2.0.7-rc stuff: conditions, num_cpus_hint, dns server…
174 .Interface
175 [code,C]
176 --------
177 int event_config_set_num_cpus_hint(struct event_config *cfg, int cpus)
178 --------
179
180 This function is currently only useful with Windows when using IOCP, though
181 it may become useful for other platforms in the future. Calling it tells the
182 event_config that the event_base it generates should try to make good use of
183 a given number of CPUs when multithreading. Note that this is only a hint:
184 the event base may wind up using more or fewer CPUs than you select.
53babe01 »
2010-01-29 Make all examples compile correctly
185
7ce95ded »
2012-04-18 Add documentation for some functions in 2.1.1-alpha
186 .Interface
187 [code,C]
188 -----
189 int event_config_set_max_dispatch_interval(struct event_config *cfg,
190 const struct timeval *max_interval, int max_callbacks,
191 int min_priority);
192 -----
193
194 This function prevents priority inversion by limiting how many low-priority
195 event callbacks can be invoked before checking for more high-priority events.
196 If max_interval is non-null, the event loop checks the time after each
197 callback, and re-scans for high-priority events if max_interval has passed.
198 If max_callbacks is nonnegative, the event loop also checks for more events
199 after max_callbacks callbacks have been invoked. These rules apply to any
200 event of min_priority or higher.
201
202
53babe01 »
2010-01-29 Make all examples compile correctly
203 //BUILD: FUNCTIONBODY INC:event2/event.h
7ce95ded »
2012-04-18 Add documentation for some functions in 2.1.1-alpha
204 .Example: Preferring edge-triggered backends
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
205 [code,C]
206 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
207 struct event_config *cfg;
53babe01 »
2010-01-29 Make all examples compile correctly
208 struct event_base *base;
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
209 int i;
210
211 /* My program wants to use edge-triggered events if at all possible. So
212 I'll try to get a base twice: Once insisting on edge-triggered IO, and
213 once not. */
214 for (i=0; i<2; ++i) {
215 cfg = event_config_new();
216
217 /* I don't like select. */
218 event_config_avoid_method(cfg, "select");
219
220 if (i == 0)
221 event_config_require_features(cfg, EV_FEATURE_ET);
222
223 base = event_base_new_with_config(cfg);
224 event_config_free(cfg);
225 if (base)
226 break;
227
228 /* If we get here, event_base_new_with_config() returned NULL. If
229 this is the first time around the loop, we'll try again without
230 setting EV_FEATURE_ET. If this is the second time around the
231 loop, we'll give up. */
232 }
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
233 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
234
7ce95ded »
2012-04-18 Add documentation for some functions in 2.1.1-alpha
235 //BUILD: FUNCTIONBODY INC:event2/event.h
236 .Example: Avoiding priority-inversion
237 [code,C]
238 ------
239 struct event_config *cfg;
240 struct event_base *base;
241
242 cfg = event_config_new();
243 if (!cfg)
244 /* Handle error */;
245
246 /* I'm going to have events running at two priorities. I expect that
247 some of my priority-1 events are going to have pretty slow callbacks,
248 so I don't want more than 100 msec to elapse (or 5 callbacks) before
249 checking for priority-0 events. */
250 struct timeval msec_100 = { 0, 100*1000 };
251 event_config_set_max_dispatch_interval(cfg, &msec_100, 5, 1);
252
253 base = event_base_new_with_config(cfg);
254 if (!base)
255 /* Handle error */;
256
257 event_base_priority_init(base, 2);
258 ------
259
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
260 These functions and types are declared in <event2/event.h>.
261
262 The EVENT_BASE_FLAG_IGNORE_ENV flag first appeared in Libevent 2.0.2-alpha.
7ce95ded »
2012-04-18 Add documentation for some functions in 2.1.1-alpha
263 The EVENT_BASE_FLAG_PRECISE_TIMER flag first appeared in Libevent
264 2.1.2-alpha. The event_config_set_num_cpus_hint() function was new in Libevent
265 2.0.7-rc, and event_config_set_max_dispatch_interval() was new in 2.1.1-alpha.
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
266 Everything else in this section first appeared in Libevent 2.0.1-alpha.
267
268 Examining an event_base's backend method
269 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
270
271 Sometimes you want to see which features are actually available in an
272 event_base, or which method it's using.
273
274 .Interface
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
275 [code,C]
276 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
277 const char **event_get_supported_methods(void);
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
278 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
279
280 The event_get_supported_methods() function returns a pointer to an array of
281 the names of the methods supported in this version of Libevent. The
282 last element in the array is NULL.
283
53babe01 »
2010-01-29 Make all examples compile correctly
284 //BUILD: FUNCTIONBODY INC:event2/event.h
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
285 .Example
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
286 [code,C]
287 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
288 int i;
6f89afcf »
2010-02-02 Make the examples build without warnings
289 const char **methods = event_get_supported_methods();
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
290 printf("Starting Libevent %s. Available methods are:\n",
291 event_get_version());
292 for (i=0; methods[i] != NULL; ++i) {
293 printf(" %s\n", methods[i]);
294 }
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
295 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
296
297 NOTE: This function returns a list of the methods that Libevent was compiled
298 to support. It is possible that your operating system will not in fact
85b35f18 »
2009-04-24 Initial editing pass from Susan.
299 support them all when Libevent tries to run. For example, you could be on a
300 version of OSX where kqueue is too buggy to use.
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
301
302 .Interface
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
303 [code,C]
304 --------
0b1e73a0 »
2010-02-02 Note a few functions that just got const-ized
305 const char *event_base_get_method(const struct event_base *base);
306 enum event_method_feature event_base_get_features(const struct event_base *base);
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
307 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
308
309 The event_base_get_method() call returns the name of the actual method in use
310 by an event_base. The event_base_get_features() call returns a bitmask of
311 the features that it supports.
312
53babe01 »
2010-01-29 Make all examples compile correctly
313 //BUILD: FUNCTIONBODY INC:event2/event.h
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
314 .Example
53babe01 »
2010-01-29 Make all examples compile correctly
315 [code,C]
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
316 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
317 struct event_base *base;
53babe01 »
2010-01-29 Make all examples compile correctly
318 enum event_method_feature f;
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
319
320 base = event_base_new();
321 if (!base) {
322 puts("Couldn't get an event_base!");
323 } else {
324 printf("Using Libevent with backend method %s.",
325 event_base_get_method(base));
326 f = event_base_get_features(base);
327 if ((f & EV_FEATURE_ET))
328 printf(" Edge-triggered events are supported.");
3d498101 »
2010-02-20 Fix a constant in feature-detection example.
329 if ((f & EV_FEATURE_O1))
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
330 printf(" O(1) event notification is supported.");
331 if ((f & EV_FEATURE_FDS))
332 printf(" All FD types are supported.");
333 puts("");
334 }
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
335 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
336
337 These functions are defined in <event2/event.h>. The event_base_get_method()
338 call was first available in Libevent 1.4.3. The others first appeared in
339 Libevent 2.0.1-alpha.
340
341 Deallocating an event_base
342 ~~~~~~~~~~~~~~~~~~~~~~~~~~
343
344 When you are finished with an event_base, you can deallocate it with
345 event_base_free().
346
347 .Interface
53babe01 »
2010-01-29 Make all examples compile correctly
348 [code,C]
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
349 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
350 void event_base_free(struct event_base *base);
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
351 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
352
353 Note that this function does not deallocate any of the events that are
354 currently associated with the event_base, or close any of their sockets, or
355 free any of their pointers.
356
357 The event_base_free() function is defined in <event2/event.h>. It was first
358 implemented in Libevent 1.2.
359
360
361 Setting priorities on an event_base
362 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
363
364 Libevent supports setting multiple priorities on an event. By default,
365 though, an event_base supports only a single priority level. You can set the
366 number of priorities on an event_base by calling event_base_priority_init().
367
368 .Interface
53babe01 »
2010-01-29 Make all examples compile correctly
369 [code,C]
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
370 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
371 int event_base_priority_init(struct event_base *base, int n_priorities);
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
372 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
373
374 This function returns 0 on success and -1 on failure. The 'base' argument is
375 the event_base to modify, and n_priorities is the number of priorities to
376 support. It must be at least 1. The available priorities for new events
377 will be numbered from 0 (most important) to n_priorities-1 (least important).
378
6d74d834 »
2010-02-02 Clarify that npriorities has a hard limit
379 There is a constant, EVENT_MAX_PRIORITIES, that sets the upper bound on the
380 value of n_priorities. It is an error to call this function with a higher
381 value for n_priorities.
382
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
383 NOTE: You *must* call this function before any events become active. It is
384 best to call it immediately after creating the event_base.
385
7ce95ded »
2012-04-18 Add documentation for some functions in 2.1.1-alpha
386
387 To find the number of priorities currently supported by a base, you can
388 call event_base_getnpriorities().
389
390 .Interface
391 [code,C]
392 -----
393 int event_base_get_npriorities(struct event_base *base);
394 -----
395
396 The return value is equal to the number of priorities configured in the
397 base. So if event_base_get_npriorities() returns 3, then allowable priority
398 values are 0, 1, and 2.
399
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
400 .Example
401
7ce95ded »
2012-04-18 Add documentation for some functions in 2.1.1-alpha
402 -------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
403 For an example, see the documentation for event_priority_set below.
7ce95ded »
2012-04-18 Add documentation for some functions in 2.1.1-alpha
404 -------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
405
406 By default, all new events associated with this base will be initialized
407 with priority equal to n_priorities / 2.
408
409 The event_base_priority_init function is defined in <event2/event.h>. It has
7ce95ded »
2012-04-18 Add documentation for some functions in 2.1.1-alpha
410 been available since Libevent 1.0. The event_base_get_npriorities() function
411 was new in Libevent 2.1.1-alpha.
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
412
413
414 Reinitializing an event_base after fork()
415 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
416
417 Not all event backends persist cleanly after a call to fork(). Thus, if your
418 program uses fork() or a related system call in order to start a new process,
419 and you want to continue using an event_base after you have forked, you may
420 need to reinitialize it.
421
422 .Interface
53babe01 »
2010-01-29 Make all examples compile correctly
423 [code,C]
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
424 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
425 int event_reinit(struct event_base *base);
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
426 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
427
428 The function returns 0 on success, -1 on failure.
429
53babe01 »
2010-01-29 Make all examples compile correctly
430 //BUILD: FUNCTIONBODY INC:event2/event.h INC:../example_stubs/Ref2.h INC:unistd.h
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
431 .Example
53babe01 »
2010-01-29 Make all examples compile correctly
432 [code,C]
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
433 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
434 struct event_base *base = event_base_new();
435
436 /* ... add some events to the event_base ... */
437
438 if (fork()) {
439 /* In parent */
440 continue_running_parent(base); /*...*/
441 } else {
442 /* In child */
443 event_reinit(base);
444 continue_running_child(base); /*...*/
445 }
ebf2f53e »
2009-04-22 Add proper incantations to get correct, highlighted source in everyth…
446 --------
b71b5e5f »
2009-04-22 Insert a license file and start writing the reference manual
447
448 The event_reinit() function is defined in <event2/event.h>. It was first
449 available in Libevent 1.4.3-alpha.
6b4d13aa »
2009-05-02 Add notes on working with deprecated functions
450
451
452 Obsolete event_base functions
453 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
454
455 Older versions of Libevent relied pretty heavily on the idea of a
456 "current" event_base. The "current" event_base was a global setting
457 shared across all threads. If you forgot to specify which event_base
458 you wanted, you got the current one. Since event_bases weren't
459 threadsafe, this could get pretty error-prone.
460
461 Instead of event_base_new(), there was:
462
463 .Interface
53babe01 »
2010-01-29 Make all examples compile correctly
464 [code,C]
6b4d13aa »
2009-05-02 Add notes on working with deprecated functions
465 --------
466 struct event_base *event_init(void);
467 --------
468
469 This function worked like event_base_new(), and set the current base
3f426202 »
2009-05-23 typo cleanup
470 to the allocated base. There was no other way to change the
54524652 »
2009-05-28 spell-check.
471 current base.
6b4d13aa »
2009-05-02 Add notes on working with deprecated functions
472
473 Some of the event_base functions in this section had variants that
474 operated on the current base. These functions behaved as the current
475 functions, except that they took no base argument.
476
477 [options="header",width="85%"]
478 |======================================================================
479 | Current function | Obsolete current-base version
480 | event_base_priority_init() | event_priority_init()
481 | event_base_get_method() | event_get_method()
482 |======================================================================
483
Something went wrong with that request. Please try again.