27 #ifndef _EVENT_INTERNAL_H_
28 #define _EVENT_INTERNAL_H_
34 #include "event2/event-config.h"
36 #include <sys/queue.h>
38 #include "minheap-internal.h"
39 #include "evsignal-internal.h"
40 #include "mm-internal.h"
41 #include "defer-internal.h"
46 #define ev_signal_next _ev.ev_signal.ev_signal_next
47 #define ev_io_next _ev.ev_io.ev_io_next
48 #define ev_io_timeout _ev.ev_io.ev_timeout
51 #define ev_ncalls _ev.ev_signal.ev_ncalls
52 #define ev_pncalls _ev.ev_signal.ev_pncalls
55 #define EV_CLOSURE_NONE 0
56 #define EV_CLOSURE_SIGNAL 1
57 #define EV_CLOSURE_PERSIST 2
113 #include "ht-internal.h"
114 struct event_map_entry;
115 HT_HEAD(event_io_map, event_map_entry);
117 #define event_io_map event_signal_map
138 struct event_list events;
141 struct timeval duration;
144 struct event timeout_event;
159 #ifndef _EVENT_DISABLE_DEBUG_MODE
161 extern int _event_debug_mode_on;
162 #define EVENT_DEBUG_MODE_IS_ON() (_event_debug_mode_on)
164 #define EVENT_DEBUG_MODE_IS_ON() (0)
225 struct event_io_map
io;
243 #if defined(_EVENT_HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
246 struct timeval tv_clock_diff;
248 time_t last_updated_clock_diff;
251 #ifndef _EVENT_DISABLE_THREAD_SUPPORT
268 struct event_iocp_port *iocp;
291 const char *avoid_method;
305 #if defined(_EVENT_HAVE_SYS_QUEUE_H) && !defined(_EVENT_HAVE_TAILQFOREACH)
307 #define TAILQ_FIRST(head) ((head)->tqh_first)
310 #define TAILQ_END(head) NULL
313 #define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
316 #ifndef TAILQ_FOREACH
317 #define TAILQ_FOREACH(var, head, field) \
318 for ((var) = TAILQ_FIRST(head); \
319 (var) != TAILQ_END(head); \
320 (var) = TAILQ_NEXT(var, field))
323 #ifndef TAILQ_INSERT_BEFORE
324 #define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
325 (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
326 (elm)->field.tqe_next = (listelm); \
327 *(listelm)->field.tqe_prev = (elm); \
328 (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
333 #define N_ACTIVE_CALLBACKS(base) \
334 ((base)->event_count_active + (base)->defer_queue.active_count)
336 int _evsig_set_handler(
struct event_base *base,
int evsignal,
338 int _evsig_restore_handler(
struct event_base *base,
int evsignal);
341 void event_active_nolock(
struct event *ev,
int res,
short count);
344 void event_base_add_virtual(
struct event_base *base);
345 void event_base_del_virtual(
struct event_base *base);
int event_count
Number of total events added to this event_base.
Definition: event-internal.h:187
void * current_event_cond
A condition that gets signalled when we're done processing an event with waiters on it...
Definition: event-internal.h:261
struct event_signal_map sigmap
Mapping from signal numbers to enabled (added) events.
Definition: event-internal.h:228
struct min_heap timeheap
Priority queue of events with timeouts.
Definition: event-internal.h:237
Internal structure: describes the configuration we want for an event_base that we're about to allocat...
Definition: event-internal.h:296
struct timeval tv_cache
Stored timeval: used to avoid calling gettimeofday/clock_gettime too often.
Definition: event-internal.h:241
int event_count_active
Number of total events active in this event_base.
Definition: event-internal.h:189
int event_break
Set if we should terminate the loop immediately.
Definition: event-internal.h:195
struct event_changelist changelist
List of changes to tell backend about at next dispatch.
Definition: event-internal.h:176
Structure to represent a single event.
Definition: event_struct.h:87
Definition: evsignal-internal.h:39
int n_common_timeouts_allocated
The total size of common_timeout_queues.
Definition: event-internal.h:218
int event_gotterm
Set if we should terminate the loop once we're done processing events.
Definition: event-internal.h:193
void(* dealloc)(struct event_base *)
Function to clean up and free our data from the event_base.
Definition: event-internal.h:87
Structure to define the backend of a given event_base.
Definition: event-internal.h:60
Definition: event-internal.h:124
struct event_io_map io
Mapping from file descriptors to enabled (added) events.
Definition: event-internal.h:225
int current_event_waiters
Number of threads blocking on current_event_cond.
Definition: event-internal.h:263
void * th_base_lock
A lock to prevent conflicting accesses to this event_base.
Definition: event-internal.h:256
struct event * current_event
The event whose callback is executing right now.
Definition: event-internal.h:258
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition: util.h:278
int nactivequeues
The length of the activequeues array.
Definition: event-internal.h:208
int is_notify_pending
True if the base already has a pending notify, and we don't need to add any more. ...
Definition: event-internal.h:277
int(* del)(struct event_base *, evutil_socket_t fd, short old, short events, void *fdinfo)
As "add", except 'events' contains the events we mean to disable.
Definition: event-internal.h:79
int running_loop
Set if we're running the event_base_loop function, to prevent reentrant invocation.
Definition: event-internal.h:199
enum event_base_config_flag flags
Flags that this base was configured with.
Definition: event-internal.h:272
struct event_list * activequeues
An array of nactivequeues queues for active events (ones that have triggered, and whose callbacks nee...
Definition: event-internal.h:206
int n_common_timeouts
The number of entries used in common_timeout_queues.
Definition: event-internal.h:216
Structures used by event.h.
int virtual_event_count
Number of virtual events.
Definition: event-internal.h:185
Represents a.
Definition: changelist-internal.h:53
struct event th_notify
An event used by some th_notify functions to wake up the main thread.
Definition: event-internal.h:283
event_base_config_flag
A flag passed to event_config_set_flag().
Definition: event.h:447
Definition: event-internal.h:153
void * evbase
Pointer to backend-specific data.
Definition: event-internal.h:172
const struct eventop * evsel
Function pointers and other data to describe this event_base's backend.
Definition: event-internal.h:170
const struct eventop * evsigsel
Function pointers used to describe the backend that this event_base uses for signals.
Definition: event-internal.h:180
Definition: event-internal.h:136
unsigned long th_owner_id
The thread currently running the event_loop for this base.
Definition: event-internal.h:254
Definition: event-internal.h:288
struct common_timeout_list ** common_timeout_queues
An array of common_timeout_list* for all of the common timeout values we know.
Definition: event-internal.h:214
struct timeval event_tv
Stored timeval; used to detect when time is running backwards.
Definition: event-internal.h:234
int need_reinit
Flag: set if we need to reinitialize the event base after we fork.
Definition: event-internal.h:90
const char * name
The name of this backend.
Definition: event-internal.h:62
int(* th_notify_fn)(struct event_base *base)
A function used to wake up the main thread from another thread.
Definition: event-internal.h:285
enum event_method_feature features
Bit-array of supported event_method_features that this backend can provide.
Definition: event-internal.h:93
int(* dispatch)(struct event_base *, struct timeval *)
Function to implement the core of an event loop.
Definition: event-internal.h:85
struct deferred_cb_queue defer_queue
List of defered_cb that are active.
Definition: event-internal.h:222
struct evsig_info sig
Data to implement the common signal handelr code.
Definition: event-internal.h:182
int(* add)(struct event_base *, evutil_socket_t fd, short old, short events, void *fdinfo)
Enable reading/writing on a given fd or signal.
Definition: event-internal.h:77
struct event_list eventqueue
All events that have been enabled (added) in this event_base.
Definition: event-internal.h:231
evutil_socket_t th_notify_fd[2]
A socketpair used by some th_notify functions to wake up the main thread.
Definition: event-internal.h:280
size_t fdinfo_len
Length of the extra information we should record for each fd that has one or more active events...
Definition: event-internal.h:99
Definition: event-internal.h:167
event_method_feature
A flag used to describe which features an event_base (must) provide.
Definition: event.h:426
A deferred_cb_queue is a list of deferred_cb that we can add to and run.
Definition: defer-internal.h:54
Definition: minheap-internal.h:38