libevent
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
event2
event.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
3
* Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
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 _EVENT2_EVENT_H_
28
#define _EVENT2_EVENT_H_
29
183
#ifdef __cplusplus
184
extern
"C"
{
185
#endif
186
187
#include <event2/event-config.h>
188
#ifdef _EVENT_HAVE_SYS_TYPES_H
189
#include <sys/types.h>
190
#endif
191
#ifdef _EVENT_HAVE_SYS_TIME_H
192
#include <sys/time.h>
193
#endif
194
195
#include <stdio.h>
196
197
/* For int types. */
198
#include <
event2/util.h
>
199
213
struct
event_base
214
#ifdef _EVENT_IN_DOXYGEN
215
{
/*Empty body so that doxygen will generate documentation here.*/
}
216
#endif
217
;
218
272
struct
event
273
#ifdef _EVENT_IN_DOXYGEN
274
{
/*Empty body so that doxygen will generate documentation here.*/
}
275
#endif
276
;
277
291
struct
event_config
292
#ifdef _EVENT_IN_DOXYGEN
293
{
/*Empty body so that doxygen will generate documentation here.*/
}
294
#endif
295
;
296
317
void
event_enable_debug_mode
(
void
);
318
328
void
event_debug_unassign
(
struct
event
*);
329
337
struct
event_base
*
event_base_new
(
void
);
338
349
int
event_reinit
(
struct
event_base
*base);
350
364
int
event_base_dispatch
(
struct
event_base
*);
365
372
const
char
*
event_base_get_method
(
const
struct
event_base
*);
373
386
const
char
**
event_get_supported_methods
(
void
);
387
398
struct
event_config
*
event_config_new
(
void
);
399
405
void
event_config_free
(
struct
event_config
*cfg);
406
419
int
event_config_avoid_method
(
struct
event_config
*cfg,
const
char
*method);
420
430
enum
event_method_feature
{
432
EV_FEATURE_ET
= 0x01,
437
EV_FEATURE_O1
= 0x02,
440
EV_FEATURE_FDS
= 0x04
441
};
442
451
enum
event_base_config_flag
{
454
EVENT_BASE_FLAG_NOLOCK
= 0x01,
457
EVENT_BASE_FLAG_IGNORE_ENV
= 0x02,
464
EVENT_BASE_FLAG_STARTUP_IOCP
= 0x04,
468
EVENT_BASE_FLAG_NO_CACHE_TIME
= 0x08,
469
484
EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST
= 0x10
485
};
486
494
int
event_base_get_features
(
const
struct
event_base
*base);
495
518
int
event_config_require_features
(
struct
event_config
*cfg,
int
feature);
519
526
int
event_config_set_flag
(
struct
event_config
*cfg,
int
flag);
527
537
int
event_config_set_num_cpus_hint
(
struct
event_config
*cfg,
int
cpus);
538
551
struct
event_base
*
event_base_new_with_config
(
const
struct
event_config
*);
552
561
void
event_base_free
(
struct
event_base
*);
562
566
#define _EVENT_LOG_DEBUG 0
567
#define _EVENT_LOG_MSG 1
568
#define _EVENT_LOG_WARN 2
569
#define _EVENT_LOG_ERR 3
570
577
typedef
void (*
event_log_cb
)(
int
severity,
const
char
*msg);
588
void
event_set_log_callback
(
event_log_cb
cb);
589
595
typedef
void (*
event_fatal_cb
)(
int
err);
596
609
void
event_set_fatal_callback
(
event_fatal_cb
cb);
610
620
int
event_base_set
(
struct
event_base
*,
struct
event
*);
621
629
#define EVLOOP_ONCE 0x01
630
632
#define EVLOOP_NONBLOCK 0x02
633
653
int
event_base_loop
(
struct
event_base
*,
int
);
654
670
int
event_base_loopexit
(
struct
event_base
*,
const
struct
timeval *);
671
685
int
event_base_loopbreak
(
struct
event_base
*);
686
699
int
event_base_got_exit
(
struct
event_base
*);
700
713
int
event_base_got_break
(
struct
event_base
*);
714
724
#define EV_TIMEOUT 0x01
725
726
#define EV_READ 0x02
727
728
#define EV_WRITE 0x04
729
730
#define EV_SIGNAL 0x08
731
737
#define EV_PERSIST 0x10
738
739
#define EV_ET 0x20
740
747
#define evtimer_assign(ev, b, cb, arg) \
748
event_assign((ev), (b), -1, 0, (cb), (arg))
749
#define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg))
750
#define evtimer_add(ev, tv) event_add((ev), (tv))
751
#define evtimer_del(ev) event_del(ev)
752
#define evtimer_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv))
753
#define evtimer_initialized(ev) event_initialized(ev)
754
762
#define evsignal_add(ev, tv) event_add((ev), (tv))
763
#define evsignal_assign(ev, b, x, cb, arg) \
764
event_assign((ev), (b), (x), EV_SIGNAL|EV_PERSIST, cb, (arg))
765
#define evsignal_new(b, x, cb, arg) \
766
event_new((b), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
767
#define evsignal_del(ev) event_del(ev)
768
#define evsignal_pending(ev, tv) event_pending((ev), EV_SIGNAL, (tv))
769
#define evsignal_initialized(ev) event_initialized(ev)
770
783
typedef
void (*
event_callback_fn
)(
evutil_socket_t
, short,
void
*);
784
833
struct
event
*
event_new
(
struct
event_base
*, evutil_socket_t,
short
,
event_callback_fn
,
void
*);
834
835
874
int
event_assign
(
struct
event
*,
struct
event_base
*, evutil_socket_t,
short
,
event_callback_fn
,
void
*);
875
882
void
event_free
(
struct
event
*);
883
906
int
event_base_once
(
struct
event_base
*, evutil_socket_t,
short
,
event_callback_fn
,
void
*,
const
struct
timeval *);
907
930
int
event_add
(
struct
event
*ev,
const
struct
timeval *timeout);
931
943
int
event_del
(
struct
event
*);
944
945
960
void
event_active
(
struct
event
*ev,
int
res,
short
ncalls);
961
975
int
event_pending
(
const
struct
event
*ev,
short
events,
struct
timeval *tv);
976
977
993
int
event_initialized
(
const
struct
event
*ev);
994
998
#define event_get_signal(ev) ((int)event_get_fd(ev))
999
1004
evutil_socket_t
event_get_fd
(
const
struct
event
*ev);
1005
1009
struct
event_base
*
event_get_base
(
const
struct
event
*ev);
1010
1014
short
event_get_events
(
const
struct
event
*ev);
1015
1019
event_callback_fn
event_get_callback
(
const
struct
event
*ev);
1020
1024
void
*
event_get_callback_arg
(
const
struct
event
*ev);
1025
1033
void
event_get_assignment
(
const
struct
event
*
event
,
1034
struct
event_base
**base_out, evutil_socket_t *fd_out,
short
*events_out,
1035
event_callback_fn
*callback_out,
void
**arg_out);
1036
1050
size_t
event_get_struct_event_size
(
void
);
1051
1061
const
char
*
event_get_version
(
void
);
1062
1074
ev_uint32_t
event_get_version_number
(
void
);
1075
1077
#define LIBEVENT_VERSION _EVENT_VERSION
1078
1080
#define LIBEVENT_VERSION_NUMBER _EVENT_NUMERIC_VERSION
1081
1083
#define EVENT_MAX_PRIORITIES 256
1084
1111
int
event_base_priority_init
(
struct
event_base
*,
int
);
1112
1121
int
event_priority_set
(
struct
event
*,
int
);
1122
1142
const
struct
timeval *
event_base_init_common_timeout
(
struct
event_base
*base,
1143
const
struct
timeval *duration);
1144
1145
#if !defined(_EVENT_DISABLE_MM_REPLACEMENT) || defined(_EVENT_IN_DOXYGEN)
1146
1168
void
event_set_mem_functions
(
1169
void
*(*malloc_fn)(
size_t
sz),
1170
void
*(*realloc_fn)(
void
*ptr,
size_t
sz),
1171
void
(*free_fn)(
void
*ptr));
1174
#define EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
1175
#endif
1176
1177
void
event_base_dump_events(
struct
event_base
*, FILE *);
1178
1190
int
event_base_gettimeofday_cached
(
struct
event_base
*base,
1191
struct
timeval *tv);
1192
1193
#ifdef __cplusplus
1194
}
1195
#endif
1196
1197
#endif
/* _EVENT2_EVENT_H_ */
Generated by
1.8.1.1