00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef EVENT2_EVENT_H_INCLUDED_
00028 #define EVENT2_EVENT_H_INCLUDED_
00029
00185 #include <event2/visibility.h>
00186
00187 #ifdef __cplusplus
00188 extern "C" {
00189 #endif
00190
00191 #include <event2/event-config.h>
00192 #ifdef EVENT__HAVE_SYS_TYPES_H
00193 #include <sys/types.h>
00194 #endif
00195 #ifdef EVENT__HAVE_SYS_TIME_H
00196 #include <sys/time.h>
00197 #endif
00198
00199 #include <stdio.h>
00200
00201
00202 #include <event2/util.h>
00203
00217 struct event_base
00218 #ifdef EVENT_IN_DOXYGEN_
00219 {}
00220 #endif
00221 ;
00222
00276 struct event
00277 #ifdef EVENT_IN_DOXYGEN_
00278 {}
00279 #endif
00280 ;
00281
00295 struct event_config
00296 #ifdef EVENT_IN_DOXYGEN_
00297 {}
00298 #endif
00299 ;
00300
00321 EVENT2_EXPORT_SYMBOL
00322 void event_enable_debug_mode(void);
00323
00333 EVENT2_EXPORT_SYMBOL
00334 void event_debug_unassign(struct event *);
00335
00343 EVENT2_EXPORT_SYMBOL
00344 struct event_base *event_base_new(void);
00345
00356 EVENT2_EXPORT_SYMBOL
00357 int event_reinit(struct event_base *base);
00358
00372 EVENT2_EXPORT_SYMBOL
00373 int event_base_dispatch(struct event_base *);
00374
00381 EVENT2_EXPORT_SYMBOL
00382 const char *event_base_get_method(const struct event_base *);
00383
00396 EVENT2_EXPORT_SYMBOL
00397 const char **event_get_supported_methods(void);
00398
00402 EVENT2_EXPORT_SYMBOL
00403 int event_gettime_monotonic(struct event_base *base, struct timeval *tp);
00404
00413 #define EVENT_BASE_COUNT_ACTIVE 1U
00414
00416 #define EVENT_BASE_COUNT_VIRTUAL 2U
00417
00419 #define EVENT_BASE_COUNT_ADDED 4U
00420
00440 EVENT2_EXPORT_SYMBOL
00441 int event_base_get_num_events(struct event_base *, unsigned int);
00442
00453 EVENT2_EXPORT_SYMBOL
00454 int event_base_get_max_events(struct event_base *, unsigned int, int);
00455
00466 EVENT2_EXPORT_SYMBOL
00467 struct event_config *event_config_new(void);
00468
00474 EVENT2_EXPORT_SYMBOL
00475 void event_config_free(struct event_config *cfg);
00476
00489 EVENT2_EXPORT_SYMBOL
00490 int event_config_avoid_method(struct event_config *cfg, const char *method);
00491
00501 enum event_method_feature {
00503 EV_FEATURE_ET = 0x01,
00508 EV_FEATURE_O1 = 0x02,
00511 EV_FEATURE_FDS = 0x04,
00518 EV_FEATURE_EARLY_CLOSE = 0x08
00519 };
00520
00529 enum event_base_config_flag {
00536 EVENT_BASE_FLAG_NOLOCK = 0x01,
00539 EVENT_BASE_FLAG_IGNORE_ENV = 0x02,
00546 EVENT_BASE_FLAG_STARTUP_IOCP = 0x04,
00550 EVENT_BASE_FLAG_NO_CACHE_TIME = 0x08,
00551
00566 EVENT_BASE_FLAG_EPOLL_USE_CHANGELIST = 0x10,
00567
00573 EVENT_BASE_FLAG_PRECISE_TIMER = 0x20
00574 };
00575
00583 EVENT2_EXPORT_SYMBOL
00584 int event_base_get_features(const struct event_base *base);
00585
00608 EVENT2_EXPORT_SYMBOL
00609 int event_config_require_features(struct event_config *cfg, int feature);
00610
00617 EVENT2_EXPORT_SYMBOL
00618 int event_config_set_flag(struct event_config *cfg, int flag);
00619
00629 EVENT2_EXPORT_SYMBOL
00630 int event_config_set_num_cpus_hint(struct event_config *cfg, int cpus);
00631
00660 EVENT2_EXPORT_SYMBOL
00661 int event_config_set_max_dispatch_interval(struct event_config *cfg,
00662 const struct timeval *max_interval, int max_callbacks,
00663 int min_priority);
00664
00677 EVENT2_EXPORT_SYMBOL
00678 struct event_base *event_base_new_with_config(const struct event_config *);
00679
00691 EVENT2_EXPORT_SYMBOL
00692 void event_base_free(struct event_base *);
00693
00700 EVENT2_EXPORT_SYMBOL
00701 void event_base_free_nofinalize(struct event_base *);
00702
00706 #define EVENT_LOG_DEBUG 0
00707 #define EVENT_LOG_MSG 1
00708 #define EVENT_LOG_WARN 2
00709 #define EVENT_LOG_ERR 3
00710
00712
00713
00714 #define _EVENT_LOG_DEBUG EVENT_LOG_DEBUG
00715 #define _EVENT_LOG_MSG EVENT_LOG_MSG
00716 #define _EVENT_LOG_WARN EVENT_LOG_WARN
00717 #define _EVENT_LOG_ERR EVENT_LOG_ERR
00718
00724 typedef void (*event_log_cb)(int severity, const char *msg);
00735 EVENT2_EXPORT_SYMBOL
00736 void event_set_log_callback(event_log_cb cb);
00737
00743 typedef void (*event_fatal_cb)(int err);
00744
00757 EVENT2_EXPORT_SYMBOL
00758 void event_set_fatal_callback(event_fatal_cb cb);
00759
00760 #define EVENT_DBG_ALL 0xffffffffu
00761 #define EVENT_DBG_NONE 0
00762
00777 EVENT2_EXPORT_SYMBOL
00778 void event_enable_debug_logging(ev_uint32_t which);
00779
00789 EVENT2_EXPORT_SYMBOL
00790 int event_base_set(struct event_base *, struct event *);
00791
00799 #define EVLOOP_ONCE 0x01
00800
00802 #define EVLOOP_NONBLOCK 0x02
00803
00807 #define EVLOOP_NO_EXIT_ON_EMPTY 0x04
00808
00828 EVENT2_EXPORT_SYMBOL
00829 int event_base_loop(struct event_base *, int);
00830
00846 EVENT2_EXPORT_SYMBOL
00847 int event_base_loopexit(struct event_base *, const struct timeval *);
00848
00862 EVENT2_EXPORT_SYMBOL
00863 int event_base_loopbreak(struct event_base *);
00864
00882 EVENT2_EXPORT_SYMBOL
00883 int event_base_loopcontinue(struct event_base *);
00884
00897 EVENT2_EXPORT_SYMBOL
00898 int event_base_got_exit(struct event_base *);
00899
00912 EVENT2_EXPORT_SYMBOL
00913 int event_base_got_break(struct event_base *);
00914
00924 #define EV_TIMEOUT 0x01
00925
00926 #define EV_READ 0x02
00927
00928 #define EV_WRITE 0x04
00929
00930 #define EV_SIGNAL 0x08
00931
00937 #define EV_PERSIST 0x10
00938
00939 #define EV_ET 0x20
00940
00951 #define EV_FINALIZE 0x40
00952
00960 #define EV_CLOSED 0x80
00961
00968 #define evtimer_assign(ev, b, cb, arg) \
00969 event_assign((ev), (b), -1, 0, (cb), (arg))
00970 #define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg))
00971 #define evtimer_add(ev, tv) event_add((ev), (tv))
00972 #define evtimer_del(ev) event_del(ev)
00973 #define evtimer_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv))
00974 #define evtimer_initialized(ev) event_initialized(ev)
00975
00983 #define evsignal_add(ev, tv) event_add((ev), (tv))
00984 #define evsignal_assign(ev, b, x, cb, arg) \
00985 event_assign((ev), (b), (x), EV_SIGNAL|EV_PERSIST, cb, (arg))
00986 #define evsignal_new(b, x, cb, arg) \
00987 event_new((b), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
00988 #define evsignal_del(ev) event_del(ev)
00989 #define evsignal_pending(ev, tv) event_pending((ev), EV_SIGNAL, (tv))
00990 #define evsignal_initialized(ev) event_initialized(ev)
00991
01004 typedef void (*event_callback_fn)(evutil_socket_t, short, void *);
01005
01028 EVENT2_EXPORT_SYMBOL
01029 void *event_self_cbarg(void);
01030
01079 EVENT2_EXPORT_SYMBOL
01080 struct event *event_new(struct event_base *, evutil_socket_t, short, event_callback_fn, void *);
01081
01082
01121 EVENT2_EXPORT_SYMBOL
01122 int event_assign(struct event *, struct event_base *, evutil_socket_t, short, event_callback_fn, void *);
01123
01130 EVENT2_EXPORT_SYMBOL
01131 void event_free(struct event *);
01132
01140 typedef void (*event_finalize_callback_fn)(struct event *, void *);
01175 EVENT2_EXPORT_SYMBOL
01176 int event_finalize(unsigned, struct event *, event_finalize_callback_fn);
01177 EVENT2_EXPORT_SYMBOL
01178 int event_free_finalize(unsigned, struct event *, event_finalize_callback_fn);
01205 EVENT2_EXPORT_SYMBOL
01206 int event_base_once(struct event_base *, evutil_socket_t, short, event_callback_fn, void *, const struct timeval *);
01207
01229 EVENT2_EXPORT_SYMBOL
01230 int event_add(struct event *ev, const struct timeval *timeout);
01231
01241 EVENT2_EXPORT_SYMBOL
01242 int event_remove_timer(struct event *ev);
01243
01255 EVENT2_EXPORT_SYMBOL
01256 int event_del(struct event *);
01257
01266 EVENT2_EXPORT_SYMBOL
01267 int event_del_noblock(struct event *ev);
01276 EVENT2_EXPORT_SYMBOL
01277 int event_del_block(struct event *ev);
01278
01293 EVENT2_EXPORT_SYMBOL
01294 void event_active(struct event *ev, int res, short ncalls);
01295
01309 EVENT2_EXPORT_SYMBOL
01310 int event_pending(const struct event *ev, short events, struct timeval *tv);
01311
01318 EVENT2_EXPORT_SYMBOL
01319 struct event *event_base_get_running_event(struct event_base *base);
01320
01336 EVENT2_EXPORT_SYMBOL
01337 int event_initialized(const struct event *ev);
01338
01342 #define event_get_signal(ev) ((int)event_get_fd(ev))
01343
01348 EVENT2_EXPORT_SYMBOL
01349 evutil_socket_t event_get_fd(const struct event *ev);
01350
01354 EVENT2_EXPORT_SYMBOL
01355 struct event_base *event_get_base(const struct event *ev);
01356
01360 EVENT2_EXPORT_SYMBOL
01361 short event_get_events(const struct event *ev);
01362
01366 EVENT2_EXPORT_SYMBOL
01367 event_callback_fn event_get_callback(const struct event *ev);
01368
01372 EVENT2_EXPORT_SYMBOL
01373 void *event_get_callback_arg(const struct event *ev);
01374
01379 EVENT2_EXPORT_SYMBOL
01380 int event_get_priority(const struct event *ev);
01381
01389 EVENT2_EXPORT_SYMBOL
01390 void event_get_assignment(const struct event *event,
01391 struct event_base **base_out, evutil_socket_t *fd_out, short *events_out,
01392 event_callback_fn *callback_out, void **arg_out);
01393
01407 EVENT2_EXPORT_SYMBOL
01408 size_t event_get_struct_event_size(void);
01409
01419 EVENT2_EXPORT_SYMBOL
01420 const char *event_get_version(void);
01421
01433 EVENT2_EXPORT_SYMBOL
01434 ev_uint32_t event_get_version_number(void);
01435
01437 #define LIBEVENT_VERSION EVENT__VERSION
01438
01440 #define LIBEVENT_VERSION_NUMBER EVENT__NUMERIC_VERSION
01441
01443 #define EVENT_MAX_PRIORITIES 256
01444
01471 EVENT2_EXPORT_SYMBOL
01472 int event_base_priority_init(struct event_base *, int);
01473
01481 EVENT2_EXPORT_SYMBOL
01482 int event_base_get_npriorities(struct event_base *eb);
01483
01492 EVENT2_EXPORT_SYMBOL
01493 int event_priority_set(struct event *, int);
01494
01514 EVENT2_EXPORT_SYMBOL
01515 const struct timeval *event_base_init_common_timeout(struct event_base *base,
01516 const struct timeval *duration);
01517
01518 #if !defined(EVENT__DISABLE_MM_REPLACEMENT) || defined(EVENT_IN_DOXYGEN_)
01519
01541 EVENT2_EXPORT_SYMBOL
01542 void event_set_mem_functions(
01543 void *(*malloc_fn)(size_t sz),
01544 void *(*realloc_fn)(void *ptr, size_t sz),
01545 void (*free_fn)(void *ptr));
01548 #define EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
01549 #endif
01550
01561 EVENT2_EXPORT_SYMBOL
01562 void event_base_dump_events(struct event_base *, FILE *);
01563
01564
01575 EVENT2_EXPORT_SYMBOL
01576 void event_base_active_by_fd(struct event_base *base, evutil_socket_t fd, short events);
01577
01587 EVENT2_EXPORT_SYMBOL
01588 void event_base_active_by_signal(struct event_base *base, int sig);
01589
01593 typedef int (*event_base_foreach_event_cb)(const struct event_base *, const struct event *, void *);
01594
01620 EVENT2_EXPORT_SYMBOL
01621 int event_base_foreach_event(struct event_base *base, event_base_foreach_event_cb fn, void *arg);
01622
01623
01635 EVENT2_EXPORT_SYMBOL
01636 int event_base_gettimeofday_cached(struct event_base *base,
01637 struct timeval *tv);
01638
01651 EVENT2_EXPORT_SYMBOL
01652 int event_base_update_cache_time(struct event_base *base);
01653
01668 EVENT2_EXPORT_SYMBOL
01669 void libevent_global_shutdown(void);
01670
01671 #ifdef __cplusplus
01672 }
01673 #endif
01674
01675 #endif