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
572
/* Obsolete names: these are deprecated, but older programs might use them.
573
* They violate the reserved-identifier namespace. */
574
#define _EVENT_LOG_DEBUG EVENT_LOG_DEBUG
575
#define _EVENT_LOG_MSG EVENT_LOG_MSG
576
#define _EVENT_LOG_WARN EVENT_LOG_WARN
577
#define _EVENT_LOG_ERR EVENT_LOG_ERR
578
584
typedef
void (*
event_log_cb
)(
int
severity,
const
char
*msg);
595
void
event_set_log_callback
(
event_log_cb
cb);
596
602
typedef
void (*
event_fatal_cb
)(
int
err);
603
616
void
event_set_fatal_callback
(
event_fatal_cb
cb);
617
627
int
event_base_set
(
struct
event_base
*,
struct
event
*);
628
636
#define EVLOOP_ONCE 0x01
637
639
#define EVLOOP_NONBLOCK 0x02
640
660
int
event_base_loop
(
struct
event_base
*,
int
);
661
677
int
event_base_loopexit
(
struct
event_base
*,
const
struct
timeval *);
678
692
int
event_base_loopbreak
(
struct
event_base
*);
693
706
int
event_base_got_exit
(
struct
event_base
*);
707
720
int
event_base_got_break
(
struct
event_base
*);
721
731
#define EV_TIMEOUT 0x01
732
733
#define EV_READ 0x02
734
735
#define EV_WRITE 0x04
736
737
#define EV_SIGNAL 0x08
738
744
#define EV_PERSIST 0x10
745
746
#define EV_ET 0x20
747
754
#define evtimer_assign(ev, b, cb, arg) \
755
event_assign((ev), (b), -1, 0, (cb), (arg))
756
#define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg))
757
#define evtimer_add(ev, tv) event_add((ev), (tv))
758
#define evtimer_del(ev) event_del(ev)
759
#define evtimer_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv))
760
#define evtimer_initialized(ev) event_initialized(ev)
761
769
#define evsignal_add(ev, tv) event_add((ev), (tv))
770
#define evsignal_assign(ev, b, x, cb, arg) \
771
event_assign((ev), (b), (x), EV_SIGNAL|EV_PERSIST, cb, (arg))
772
#define evsignal_new(b, x, cb, arg) \
773
event_new((b), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
774
#define evsignal_del(ev) event_del(ev)
775
#define evsignal_pending(ev, tv) event_pending((ev), EV_SIGNAL, (tv))
776
#define evsignal_initialized(ev) event_initialized(ev)
777
790
typedef
void (*
event_callback_fn
)(
evutil_socket_t
, short,
void
*);
791
840
struct
event
*
event_new
(
struct
event_base
*, evutil_socket_t,
short
,
event_callback_fn
,
void
*);
841
842
881
int
event_assign
(
struct
event
*,
struct
event_base
*, evutil_socket_t,
short
,
event_callback_fn
,
void
*);
882
889
void
event_free
(
struct
event
*);
890
913
int
event_base_once
(
struct
event_base
*, evutil_socket_t,
short
,
event_callback_fn
,
void
*,
const
struct
timeval *);
914
937
int
event_add
(
struct
event
*ev,
const
struct
timeval *timeout);
938
950
int
event_del
(
struct
event
*);
951
952
967
void
event_active
(
struct
event
*ev,
int
res,
short
ncalls);
968
982
int
event_pending
(
const
struct
event
*ev,
short
events,
struct
timeval *tv);
983
984
1000
int
event_initialized
(
const
struct
event
*ev);
1001
1005
#define event_get_signal(ev) ((int)event_get_fd(ev))
1006
1011
evutil_socket_t
event_get_fd
(
const
struct
event
*ev);
1012
1016
struct
event_base
*
event_get_base
(
const
struct
event
*ev);
1017
1021
short
event_get_events
(
const
struct
event
*ev);
1022
1026
event_callback_fn
event_get_callback
(
const
struct
event
*ev);
1027
1031
void
*
event_get_callback_arg
(
const
struct
event
*ev);
1032
1040
void
event_get_assignment
(
const
struct
event
*
event
,
1041
struct
event_base
**base_out, evutil_socket_t *fd_out,
short
*events_out,
1042
event_callback_fn
*callback_out,
void
**arg_out);
1043
1057
size_t
event_get_struct_event_size
(
void
);
1058
1068
const
char
*
event_get_version
(
void
);
1069
1081
ev_uint32_t
event_get_version_number
(
void
);
1082
1084
#define LIBEVENT_VERSION _EVENT_VERSION
1085
1087
#define LIBEVENT_VERSION_NUMBER _EVENT_NUMERIC_VERSION
1088
1090
#define EVENT_MAX_PRIORITIES 256
1091
1118
int
event_base_priority_init
(
struct
event_base
*,
int
);
1119
1128
int
event_priority_set
(
struct
event
*,
int
);
1129
1149
const
struct
timeval *
event_base_init_common_timeout
(
struct
event_base
*base,
1150
const
struct
timeval *duration);
1151
1152
#if !defined(_EVENT_DISABLE_MM_REPLACEMENT) || defined(_EVENT_IN_DOXYGEN)
1153
1175
void
event_set_mem_functions
(
1176
void
*(*malloc_fn)(
size_t
sz),
1177
void
*(*realloc_fn)(
void
*ptr,
size_t
sz),
1178
void
(*free_fn)(
void
*ptr));
1181
#define EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
1182
#endif
1183
1184
void
event_base_dump_events(
struct
event_base
*, FILE *);
1185
1197
int
event_base_gettimeofday_cached
(
struct
event_base
*base,
1198
struct
timeval *tv);
1199
1200
#ifdef __cplusplus
1201
}
1202
#endif
1203
1204
#endif
/* _EVENT2_EVENT_H_ */
Generated by
1.8.4