• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-12-stable/contrib/libevent/include/event2/

Lines Matching defs:event

35   Libevent is an event notification library for developing scalable network
37 function when a specific event occurs on a file descriptor or after a
41 Libevent is meant to replace the event loop found in event driven network
43 remove events dynamically without having to change the event loop.
47 epoll(4), and evports. The internal event mechanism is completely
48 independent of the exposed event API, and a simple update of Libevent can
51 the most scalable event notification mechanism available on an operating
57 Every program that uses Libevent must include the <event2/event.h>
59 -levent_core if you only want the main event and buffered IO-based code,
75 @section base Creating an event base
81 Every event is associated with a single event_base.
83 @section event Event notification
86 event structure with event_new(). (You may also declare an event
89 of monitored events by calling event_add(). The event structure must
105 Libevent provides a buffered I/O abstraction on top of the regular event
108 automatically. The user of a buffered event no longer deals directly
128 an event struct to use as a timer. To activate the timer, call
141 Libevent provides a very simple event-driven HTTP server that can be
157 event2/event.h
180 /** @file event2/event.h
182 Core functions for waiting for and receiving events, and using event bases.
191 #include <event2/event-config.h>
224 * @struct event
226 * Structure to represent a single event.
228 * An event can have some underlying condition it represents: a socket
230 * (An event that represents no underlying condition is still useful: you
236 * longer want the event, free it with event_free().
240 * An event may be "pending" (one whose condition we are watching),
245 * To make an event pending, pass it to event_add(). When doing so, you
246 * can also set a timeout for the event.
250 * also activate an event manually using event_active(). The even_base
254 * You can make an event non-pending by passing it to event_del(). This
255 * also makes the event non-active.
257 * Events can be "persistent" or "non-persistent". A non-persistent event
259 * most once per call to event_add(). A persistent event remains pending
261 * order to make it non-pending. When a persistent event with a timeout
276 struct event
309 * An event is re-assigned while it is added
310 * Any function is called on a non-assigned event
312 * Note that debugging mode uses memory to track every event that has been
325 * When debugging mode is enabled, informs Libevent that an event should no
329 * This function must only be called on a non-added event.
334 void event_debug_unassign(struct event *);
347 Reinitialize the event base after a fork
349 Some event mechanisms do not survive across fork. The event base needs
352 @param base the event base that needs to be re-initialized
362 This loop will run the event base until either there are no more pending or
376 Get the kernel event notification mechanism used by Libevent.
379 @return a string identifying the kernel event mechanism (kqueue, epoll, etc.)
385 Gets all event notification mechanisms supported by Libevent.
387 This functions returns the event mechanism in order preferred by
406 @name event type flag
415 * condition, other than a pending event, that keeps the loop from exiting. */
417 /** count the number of events which have been added to event base, including
425 Since event base has some internal events added to make some of its
430 active event will be counted twice. However, this might not be the case in
457 Allocates a new event configuration object.
459 The event configuration object can be used to change the behavior of
460 an event base.
470 Deallocates all memory associated with an event configuration object
472 @param cfg the event configuration object to be freed.
478 Enters an event method that should be avoided into the configuration.
480 This can be used to avoid event mechanisms that do not support certain
481 file descriptor types, or for debugging to avoid certain event
482 mechanisms. An application can make use of multiple event bases to
485 @param cfg the event configuration object
486 @param method the name of the event method to avoid
502 /** Require an event method that allows edge-triggered events with EV_ET. */
504 /** Require an event method where having one event triggered among
509 /** Require an event method that allows file descriptors as well as
512 /** Require an event method that allows you to use EV_CLOSED to detect
530 /** Do not allocate a lock for the event base, even if we have
547 /** Instead of checking the current time every time the event loop is
577 Return a bitmask of the features implemented by an event base. This
587 Enters a required event method feature that the application demands.
602 @param cfg the event configuration object
625 * @param cfg the event configuration object
633 * Record an interval and/or a number of callbacks after which the event base
634 * should check for new events. By default, the event base will run as many
666 Initialize the event API.
668 Use event_base_new_with_config() to initialize a new event base, taking
670 can currently be used to avoid certain event notification mechanisms.
672 @param cfg the event configuration object
674 or NULL if no event base can be created with the requested event_config.
746 Override Libevent's behavior in the event of a fatal internal error.
767 before any calls that create an event-base. You must call it before any
781 Associate a different event base with an event.
783 The event to be associated must not be currently active or pending.
785 @param eb the event base
786 @param ev the event
790 int event_base_set(struct event_base *, struct event *);
797 /** Block until we have an active event, then exit once all active events
815 By default, this loop will run the event base until either there are no more
832 Exit the event loop after the specified time
852 event_base_loop() will abort the loop after the next event is completed;
853 event_base_loopbreak() is typically invoked from this event's callback.
870 event callback finishes. If the event loop is not running, this
873 event_base_loopbreak() is typically invoked from this event's callback.
876 Subsequent invocations of event loop will proceed normally.
886 Checks if the event loop was told to exit by event_base_loopexit().
889 event_loopexit() is called, until the event loop is next entered.
892 @return true if event_base_loopexit() was called on this event base,
901 Checks if the event loop was told to abort immediately by event_base_loopbreak().
904 event_base_loopbreak() is called, until the event loop is next entered.
907 @return true if event_base_loopbreak() was called on this event base,
916 * @name event flags
932 * Persistent event: won't get removed automatically when activated.
934 * When a persistent event with a timeout becomes activated, its timeout
942 * while waiting for the event callback to complete in another thread.
945 * event_free_finalize() in order to safely tear down an event in a
994 A callback function for an event.
1007 Return a value used to specify that the event itself must be used as the callback argument.
1010 to the event's callback function. To specify that the argument to be
1011 passed to the callback function is the event that event_new() returns,
1017 struct event *ev = event_new(base, sock, events, callback, %event_self_cbarg());
1022 achieves the same result as passing the event in directly.
1032 Allocate and asssign a new event structure, ready to be added.
1034 The function event_new() returns a new event that can be used in
1036 arguments determine which conditions will trigger the event; the
1038 event becomes active.
1045 event can be triggered only by a timeout or by manual activation with
1060 When the event becomes active, the event loop will run the provided
1065 event occurred. The third event will be the callback_arg pointer that
1068 @param base the event base to which the event should be attached.
1072 @param callback callback function to be invoked when the event occurs
1075 @return a newly allocated struct event that must later be freed with
1080 struct event *event_new(struct event_base *, evutil_socket_t, short, event_callback_fn, void *);
1084 Prepare a new, already-allocated event structure to be added.
1086 The function event_assign() prepares the event structure ev to be used
1089 allocated a struct event, probably on the heap. Doing this will
1090 typically make your code depend on the size of the event structure, and
1097 event_get_struct_event_size() to determine the required size of an event
1100 Note that it is NOT safe to call this function on an event that is
1103 event_assign to change an existing event, but only if it is not active
1109 @param ev an event struct to be modified
1110 @param base the event base to which ev should be attached.
1113 @param callback callback function to be invoked when the event occurs
1122 int event_assign(struct event *, struct event_base *, evutil_socket_t, short, event_callback_fn, void *);
1125 Deallocate a struct event * returned by event_new().
1127 If the event is pending or active, first make it non-pending and
1131 void event_free(struct event *);
1140 typedef void (*event_finalize_callback_fn)(struct event *, void *);
1144 These functions are used to safely tear down an event in a multithreaded
1146 deadlocks, you will need a way to remove an event in the certainty that
1151 0 for its first argument, the event to tear down as its second argument,
1153 invoked as part of the event loop, with the event's priority.
1156 no longer work on the event, and event_del() will produce a no-op. You
1157 must not try to change the event's fields with event_assign() or
1159 callback has been invoked, you should treat the event structure as
1162 The event_free_finalize() function frees the event after it's finalized;
1166 add events, activate events, or attempt to "resucitate" the event being
1176 int event_finalize(unsigned, struct event *, event_finalize_callback_fn);
1178 int event_free_finalize(unsigned, struct event *, event_finalize_callback_fn);
1182 Schedule a one-time event
1186 caller to prepare an event structure.
1188 Note that in Libevent 2.0 and earlier, if the event is never triggered, the
1190 the internal memory will get freed by event_base_free() if the event
1196 @param events event(s) to monitor; can be any of EV_READ |
1198 @param callback callback function to be invoked when the event occurs
1200 @param timeout the maximum amount of time to wait for the event. NULL
1201 makes an EV_READ/EV_WRITE event make forever; NULL makes an
1202 EV_TIMEOUT event succees immediately.
1209 Add an event to the set of pending events.
1211 The function event_add() schedules the execution of the event 'ev' when the
1215 called if a matching event occurs. The event in the
1220 If the event in the ev argument already has a scheduled timeout, calling
1223 @param ev an event struct initialized via event_assign() or event_new()
1224 @param timeout the maximum amount of time to wait for the event, or NULL
1230 int event_add(struct event *ev, const struct timeval *timeout);
1233 Remove a timer from a pending event without removing the event itself.
1235 If the event has a scheduled timeout, this function unschedules it but
1236 leaves the event otherwise pending.
1238 @param ev an event struct initialized via event_assign() or event_new()
1242 int event_remove_timer(struct event *ev);
1245 Remove an event from the set of monitored events.
1247 The function event_del() will cancel the event in the argument ev. If the
1248 event has already executed or has never been added the call will have no
1251 @param ev an event struct to be removed from the working set
1256 int event_del(struct event *);
1259 As event_del(), but never blocks while the event's callback is running
1260 in another thread, even if the event was constructed without the
1267 int event_del_noblock(struct event *ev);
1269 As event_del(), but always blocks while the event's callback is running
1270 in another thread, even if the event was constructed with the
1277 int event_del_block(struct event *ev);
1280 Make an event active.
1282 You can use this function on a pending or a non-pending event to make it
1289 @param ev an event to make active.
1290 @param res a set of flags to pass to the event's callback.
1294 void event_active(struct event *ev, int res, short ncalls);
1297 Checks if a specific event is pending or scheduled.
1299 @param ev an event struct previously passed to event_add()
1300 @param events the requested event type; any of EV_TIMEOUT|EV_READ|
1302 @param tv if this field is not NULL, and the event has a timeout,
1306 @return true if the event is pending on any of the events in 'what', (that
1307 is to say, it has been added), or 0 if the event is not added.
1310 int event_pending(const struct event *ev, short events, struct timeval *tv);
1313 If called from within the callback for an event, returns that event.
1316 callback function for an event.
1319 struct event *event_base_get_running_event(struct event_base *base);
1322 Test if an event structure might be initialized.
1324 The event_initialized() function can be used to check if an event has been
1328 piece of memory from an initialized event, it can easily be confused by
1330 initialized event from zero.
1332 @param ev an event structure to be tested
1337 int event_initialized(const struct event *ev);
1340 Get the signal number assigned to a signal event
1345 Get the socket or signal assigned to an event, or -1 if the event has
1349 evutil_socket_t event_get_fd(const struct event *ev);
1352 Get the event_base associated with an event.
1355 struct event_base *event_get_base(const struct event *ev);
1358 Return the events (EV_READ, EV_WRITE, etc) assigned to an event.
1361 short event_get_events(const struct event *ev);
1364 Return the callback assigned to an event.
1367 event_callback_fn event_get_callback(const struct event *ev);
1370 Return the callback argument assigned to an event.
1373 void *event_get_callback_arg(const struct event *ev);
1376 Return the priority of an event.
1380 int event_get_priority(const struct event *ev);
1383 Extract _all_ of arguments given to construct a given event. The
1390 void event_get_assignment(const struct event *event,
1395 Return the size of struct event that the Libevent library was compiled
1398 This will be NO GREATER than sizeof(struct event) if you're running with
1402 Note that it might be SMALLER than sizeof(struct event) if some future
1403 version of Libevent adds extra padding to the end of struct event.
1445 Set the number of different event priorities
1457 event. By default, Libevent assigns the middle priority to all events
1475 Get the number of different event priorities.
1478 @return Number of different event priorities
1485 Assign a priority to an event.
1487 @param ev an event struct
1493 int event_priority_set(struct event *, int);
1509 schedule the event more efficiently.
1566 Activates all pending events for the given fd and event mask.
1591 * Callback for iterating events in an event base via event_base_foreach_event
1593 typedef int (*event_base_foreach_event_cb)(const struct event_base *, const struct event *, void *);
1596 Iterate over all added or active events events in an event loop, and invoke
1599 The callback must not call any function that modifies the event base, that
1600 modifies any event in the event base, or that adds or removes any event to
1601 the event base. Doing so is unsupported and will lead to undefined
1617 @return 0 if we iterated over every event, or the value returned by the
1630 processing event callbacks, and may be very inaccuate if your
1646 * event loop, or if timeval caching is disabled via