27 #ifndef _EVENT2_EVENT_H_ 28 #define _EVENT2_EVENT_H_ 187 #include <event2/event-config.h> 188 #ifdef _EVENT_HAVE_SYS_TYPES_H 189 #include <sys/types.h> 191 #ifdef _EVENT_HAVE_SYS_TIME_H 192 #include <sys/time.h> 214 #ifdef _EVENT_IN_DOXYGEN
273 #ifdef _EVENT_IN_DOXYGEN
292 #ifdef _EVENT_IN_DOXYGEN
566 #define EVENT_LOG_DEBUG 0 567 #define EVENT_LOG_MSG 1 568 #define EVENT_LOG_WARN 2 569 #define EVENT_LOG_ERR 3 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 636 #define EVLOOP_ONCE 0x01 639 #define EVLOOP_NONBLOCK 0x02 731 #define EV_TIMEOUT 0x01 735 #define EV_WRITE 0x04 737 #define EV_SIGNAL 0x08 744 #define EV_PERSIST 0x10 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) 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) 1005 #define event_get_signal(ev) ((int)event_get_fd(ev)) 1041 struct event_base **base_out, evutil_socket_t *fd_out,
short *events_out,
1084 #define LIBEVENT_VERSION _EVENT_VERSION 1087 #define LIBEVENT_VERSION_NUMBER _EVENT_NUMERIC_VERSION 1090 #define EVENT_MAX_PRIORITIES 256 1150 const struct timeval *duration);
1152 #if !defined(_EVENT_DISABLE_MM_REPLACEMENT) || defined(_EVENT_IN_DOXYGEN) 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 1184 void event_base_dump_events(
struct event_base *, FILE *);
1198 struct timeval *tv);
int event_reinit(struct event_base *base)
Reinitialize the event base after a fork.
int event_base_loopbreak(struct event_base *)
Abort the active event_base_loop() immediately.
const struct timeval * event_base_init_common_timeout(struct event_base *base, const struct timeval *duration)
Prepare an event_base to use a large number of timeouts with the same duration.
short event_get_events(const struct event *ev)
Return the events (EV_READ, EV_WRITE, etc) assigned to an event.
Do not check the EVENT_* environment variables when configuring an event_base.
Definition: event.h:457
struct event * event_new(struct event_base *, evutil_socket_t, short, event_callback_fn, void *)
Allocate and asssign a new event structure, ready to be added.
Configuration for an event_base.
Definition: event.h:291
struct event_base * event_base_new(void)
Create and return a new event_base to use with the rest of Libevent.
int event_base_set(struct event_base *, struct event *)
Associate a different event base with an event.
int event_base_priority_init(struct event_base *, int)
Set the number of different event priorities.
int event_base_dispatch(struct event_base *)
Event dispatching loop.
ev_uint32_t event_get_version_number(void)
Return a numeric representation of Libevent's version.
void(* event_log_cb)(int severity, const char *msg)
A callback function used to intercept Libevent's log messages.
Definition: event.h:584
Require an event method where having one event triggered among many is [approximately] an O(1) operat...
Definition: event.h:437
int event_assign(struct event *, struct event_base *, evutil_socket_t, short, event_callback_fn, void *)
Prepare a new, already-allocated event structure to be added.
struct event_base * event_base_new_with_config(const struct event_config *)
Initialize the event API.
Structure to represent a single event.
Definition: event.h:272
const char * event_base_get_method(const struct event_base *)
Get the kernel event notification mechanism used by Libevent.
Windows only: enable the IOCP dispatcher at startup.
Definition: event.h:464
const char ** event_get_supported_methods(void)
Gets all event notification mechanisms supported by Libevent.
void(* event_fatal_cb)(int err)
A function to be called if Libevent encounters a fatal internal error.
Definition: event.h:602
int event_config_set_num_cpus_hint(struct event_config *cfg, int cpus)
Records a hint for the number of CPUs in the system.
event_base_config_flag
A flag passed to event_config_set_flag().
Definition: event.h:451
int event_add(struct event *ev, const struct timeval *timeout)
Add an event to the set of pending events.
void event_debug_unassign(struct event *)
When debugging mode is enabled, informs Libevent that an event should no longer be considered as assi...
void event_free(struct event *)
Deallocate a struct event * returned by event_new().
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition: util.h:274
struct event_base * event_get_base(const struct event *ev)
Get the event_base associated with an event.
int event_base_loop(struct event_base *, int)
Wait for events to become active, and run their callbacks.
int event_config_require_features(struct event_config *cfg, int feature)
Enters a required event method feature that the application demands.
int event_base_gettimeofday_cached(struct event_base *base, struct timeval *tv)
Sets 'tv' to the current time (as returned by gettimeofday()), looking at the cached value in 'base' ...
event_method_feature
A flag used to describe which features an event_base (must) provide.
Definition: event.h:430
void(* event_callback_fn)(evutil_socket_t, short, void *)
A callback function for an event.
Definition: event.h:790
int event_del(struct event *)
Remove an event from the set of monitored events.
Common convenience functions for cross-platform portability and related socket manipulations.
void event_config_free(struct event_config *cfg)
Deallocates all memory associated with an event configuration object.
void event_set_fatal_callback(event_fatal_cb cb)
Override Libevent's behavior in the event of a fatal internal error.
struct event_config * event_config_new(void)
Allocates a new event configuration object.
void event_set_log_callback(event_log_cb cb)
Redirect Libevent's log messages.
Do not allocate a lock for the event base, even if we have locking set up.
Definition: event.h:454
int event_base_loopexit(struct event_base *, const struct timeval *)
Exit the event loop after the specified time.
void event_enable_debug_mode(void)
Enable some relatively expensive debugging checks in Libevent that would normally be turned off...
void event_get_assignment(const struct event *event, struct event_base **base_out, evutil_socket_t *fd_out, short *events_out, event_callback_fn *callback_out, void **arg_out)
Extract all of arguments given to construct a given event.
event_callback_fn event_get_callback(const struct event *ev)
Return the callback assigned to an event.
int event_config_avoid_method(struct event_config *cfg, const char *method)
Enters an event method that should be avoided into the configuration.
int event_initialized(const struct event *ev)
Test if an event structure might be initialized.
const char * event_get_version(void)
Get the Libevent version.
int event_config_set_flag(struct event_config *cfg, int flag)
Sets one or more flags to configure what parts of the eventual event_base will be initialized...
int event_base_got_break(struct event_base *)
Checks if the event loop was told to abort immediately by event_loopbreak().
void event_base_free(struct event_base *)
Deallocate all memory associated with an event_base, and free the base.
void event_active(struct event *ev, int res, short ncalls)
Make an event active.
int event_base_get_features(const struct event_base *base)
Return a bitmask of the features implemented by an event base.
Instead of checking the current time every time the event loop is ready to run timeout callbacks...
Definition: event.h:468
int event_base_once(struct event_base *, evutil_socket_t, short, event_callback_fn, void *, const struct timeval *)
Schedule a one-time event.
If we are using the epoll backend, this flag says that it is safe to use Libevent's internal change-l...
Definition: event.h:484
int event_base_got_exit(struct event_base *)
Checks if the event loop was told to exit by event_loopexit().
void event_set_mem_functions(void *(*malloc_fn)(size_t sz), void *(*realloc_fn)(void *ptr, size_t sz), void(*free_fn)(void *ptr))
Override the functions that Libevent uses for memory management.
Structure to hold information and state for a Libevent dispatch loop.
Definition: event.h:213
void * event_get_callback_arg(const struct event *ev)
Return the callback argument assigned to an event.
int event_pending(const struct event *ev, short events, struct timeval *tv)
Checks if a specific event is pending or scheduled.
size_t event_get_struct_event_size(void)
Return the size of struct event that the Libevent library was compiled with.
int event_priority_set(struct event *, int)
Assign a priority to an event.
Require an event method that allows edge-triggered events with EV_ET.
Definition: event.h:432
evutil_socket_t event_get_fd(const struct event *ev)
Get the socket or signal assigned to an event, or -1 if the event has no socket.
Require an event method that allows file descriptors as well as sockets.
Definition: event.h:440