27 #ifndef _EVENT2_EVENT_H_
28 #define _EVENT2_EVENT_H_
188 #include "opal_rename.h"
191 #include <event2/event-config.h>
192 #ifdef _EVENT_HAVE_SYS_TYPES_H
193 #include <sys/types.h>
195 #ifdef _EVENT_HAVE_SYS_TIME_H
196 #include <sys/time.h>
218 #ifdef _EVENT_IN_DOXYGEN
277 #ifdef _EVENT_IN_DOXYGEN
296 #ifdef _EVENT_IN_DOXYGEN
324 void event_set_debug_output(
int output);
574 #define _EVENT_LOG_DEBUG 0
575 #define _EVENT_LOG_MSG 1
576 #define _EVENT_LOG_WARN 2
577 #define _EVENT_LOG_ERR 3
585 typedef void (*
event_log_cb)(
int severity,
const char *msg);
637 #define EVLOOP_ONCE 0x01
640 #define EVLOOP_NONBLOCK 0x02
732 #define EV_TIMEOUT 0x01
736 #define EV_WRITE 0x04
738 #define EV_SIGNAL 0x08
745 #define EV_PERSIST 0x10
755 #define evtimer_assign(ev, b, cb, arg) \
756 event_assign((ev), (b), -1, 0, (cb), (arg))
757 #define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg))
758 #define evtimer_add(ev, tv) event_add((ev), (tv))
759 #define evtimer_del(ev) event_del(ev)
760 #define evtimer_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv))
761 #define evtimer_initialized(ev) event_initialized(ev)
770 #define evsignal_add(ev, tv) event_add((ev), (tv))
771 #define evsignal_assign(ev, b, x, cb, arg) \
772 event_assign((ev), (b), (x), EV_SIGNAL|EV_PERSIST, cb, (arg))
773 #define evsignal_new(b, x, cb, arg) \
774 event_new((b), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
775 #define evsignal_del(ev) event_del(ev)
776 #define evsignal_pending(ev, tv) event_pending((ev), EV_SIGNAL, (tv))
777 #define evsignal_initialized(ev) event_initialized(ev)
1006 #define event_get_signal(ev) ((int)event_get_fd(ev))
1042 struct event_base **base_out, evutil_socket_t *fd_out,
short *events_out,
1085 #define LIBEVENT_VERSION _EVENT_VERSION
1088 #define LIBEVENT_VERSION_NUMBER _EVENT_NUMERIC_VERSION
1091 #define EVENT_MAX_PRIORITIES 256
1151 const struct timeval *duration);
1153 #if !defined(_EVENT_DISABLE_MM_REPLACEMENT) || defined(_EVENT_IN_DOXYGEN)
1177 void *(*malloc_fn)(
size_t sz),
1178 void *(*realloc_fn)(
void *ptr,
size_t sz),
1179 void (*free_fn)(
void *ptr));
1182 #define EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
1185 void event_base_dump_events(
struct event_base *, FILE *);
1199 struct timeval *tv);
int event_pending(const struct event *ev, short events, struct timeval *tv)
Checks if a specific event is pending or scheduled.
Definition: event.c:1826
Require an event method where having one event triggered among many is [approximately] an O(1) operat...
Definition: event.h:433
int event_config_require_features(struct event_config *cfg, int feature)
Enters a required event method feature that the application demands.
Definition: event.c:974
int event_reinit(struct event_base *base)
Reinitialize the event base after a fork.
Definition: event.c:799
int event_base_got_break(struct event_base *)
Checks if the event loop was told to abort immediately by event_loopbreak().
Definition: event.c:1483
const char * event_base_get_method(const struct event_base *)
Get the kernel event notification mechanism used by Libevent.
Definition: event.c:1428
void event_base_free(struct event_base *)
Deallocate all memory associated with an event_base, and free the base.
Definition: event.c:691
Internal structure: describes the configuration we want for an event_base that we're about to allocat...
Definition: event-internal.h:296
void event_enable_debug_mode(void)
Enable some relatively expensive debugging checks in Libevent that would normally be turned off...
Definition: event.c:514
Require an event method that allows file descriptors as well as sockets.
Definition: event.h:436
const char * event_get_version(void)
Get the Libevent version.
Definition: event.c:2598
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...
Definition: event.c:948
struct event_config * event_config_new(void)
Allocates a new event configuration object.
Definition: event.c:915
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.
Definition: event.c:1889
Instead of checking the current time every time the event loop is ready to run timeout callbacks...
Definition: event.h:464
ev_uint32_t event_get_version_number(void)
Return a numeric representation of Libevent's version.
Definition: event.c:2604
void event_active(struct event *ev, int res, short ncalls)
Make an event active.
Definition: event.c:2246
Structure to represent a single event.
Definition: event_struct.h:87
int event_del(struct event *)
Remove an event from the set of monitored events.
Definition: event.c:2146
int event_base_loopbreak(struct event_base *)
Abort the active event_base_loop() immediately.
Definition: event.c:1464
void(* event_fatal_cb)(int err)
A function to be called if Libevent encounters a fatal internal error.
Definition: event.h:591
void * event_get_callback_arg(const struct event *ev)
Return the callback argument assigned to an event.
Definition: event.c:1917
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.
Definition: event.c:1866
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.
Definition: event.c:1695
struct event_base * event_get_base(const struct event *ev)
Get the event_base associated with an event.
Definition: event.c:1896
int event_base_loop(struct event_base *, int)
Wait for events to become active, and run their callbacks.
Definition: event.c:1511
int event_base_got_exit(struct event_base *)
Checks if the event loop was told to exit by event_loopexit().
Definition: event.c:1493
int event_priority_set(struct event *, int)
Assign a priority to an event.
Definition: event.c:1807
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition: util.h:278
void event_set_log_callback(event_log_cb cb)
Redirect Libevent's log messages.
Definition: log.c:197
int event_base_get_features(const struct event_base *base)
Return a bitmask of the features implemented by an event base.
Definition: event.c:486
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.
Definition: event.c:1766
void(* event_log_cb)(int severity, const char *msg)
A callback function used to intercept Libevent's log messages.
Definition: event.h:573
const char ** event_get_supported_methods(void)
Gets all event notification mechanisms supported by Libevent.
Definition: event.c:883
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.
Definition: event.c:1167
struct event_base * event_base_new(void)
Create and return a new event_base to use with the rest of Libevent.
Definition: event.c:442
int event_base_loopexit(struct event_base *, const struct timeval *)
Exit the event loop after the specified time.
Definition: event.c:1451
void event_set_fatal_callback(event_fatal_cb cb)
Override Libevent's behavior in the event of a fatal internal error.
Definition: log.c:71
int event_base_priority_init(struct event_base *, int)
Set the number of different event priorities.
Definition: event.c:999
int event_config_avoid_method(struct event_config *cfg, const char *method)
Enters an event method that should be avoided into the configuration.
Definition: event.c:957
Common convenience functions for cross-platform portability and related socket manipulations.
void(* event_callback_fn)(evutil_socket_t, short, void *)
A callback function for an event.
Definition: event.h:779
event_base_config_flag
A flag passed to event_config_set_flag().
Definition: event.h:447
Windows only: enable the IOCP dispatcher at startup.
Definition: event.h:460
int event_add(struct event *ev, const struct timeval *timeout)
Add an event to the set of pending events.
Definition: event.c:1924
void event_free(struct event *)
Deallocate a struct event * returned by event_new().
Definition: event.c:1781
Do not allocate a lock for the event base, even if we have locking set up.
Definition: event.h:450
int event_base_dispatch(struct event_base *)
Event dispatching loop.
Definition: event.c:1422
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' ...
Definition: event.c:386
int event_base_set(struct event_base *, struct event *)
Associate a different event base with an event.
Definition: event.c:1742
Do not check the EVENT_* environment variables when configuring an event_base.
Definition: event.h:453
void event_config_free(struct event_config *cfg)
Deallocates all memory associated with an event configuration object.
Definition: event.c:936
int event_config_set_num_cpus_hint(struct event_config *cfg, int cpus)
Records a hint for the number of CPUs in the system.
Definition: event.c:984
void event_debug_unassign(struct event *)
When debugging mode is enabled, informs Libevent that an event should no longer be considered as assi...
Definition: event.c:1793
If we are using the epoll backend, this flag says that it is safe to use Libevent's internal change-l...
Definition: event.h:480
int event_initialized(const struct event *ev)
Test if an event structure might be initialized.
Definition: event.c:1857
short event_get_events(const struct event *ev)
Return the events (EV_READ, EV_WRITE, etc) assigned to an event.
Definition: event.c:1903
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.
Definition: event.c:2683
event_callback_fn event_get_callback(const struct event *ev)
Return the callback assigned to an event.
Definition: event.c:1910
Require an event method that allows edge-triggered events with EV_ET.
Definition: event.h:428
Definition: event-internal.h:167
event_method_feature
A flag used to describe which features an event_base (must) provide.
Definition: event.h:426
size_t event_get_struct_event_size(void)
Return the size of struct event that the Libevent library was compiled with.
Definition: event.c:1883
struct event_base * event_base_new_with_config(const struct event_config *)
Initialize the event API.
Definition: event.c:557
int event_base_once(struct event_base *, evutil_socket_t, short, event_callback_fn, void *, const struct timeval *)
Schedule a one-time event.
Definition: event.c:1648