• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-12-stable/contrib/ntp/sntp/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
785 Associate a different event base with an event.
787 The event to be associated must not be currently active or pending.
789 @param eb the event base
790 @param ev the event
794 int event_base_set(struct event_base *, struct event *);
801 /** Block until we have an active event, then exit once all active events
819 By default, this loop will run the event base until either there are no more
836 Exit the event loop after the specified time
856 event_base_loop() will abort the loop after the next event is completed;
857 event_base_loopbreak() is typically invoked from this event's callback.
874 event callback finishes. If the event loop is not running, this
877 event_base_loopbreak() is typically invoked from this event's callback.
880 Subsequent invocations of event loop will proceed normally.
890 Checks if the event loop was told to exit by event_base_loopexit().
893 event_loopexit() is called, until the event loop is next entered.
896 @return true if event_base_loopexit() was called on this event base,
905 Checks if the event loop was told to abort immediately by event_base_loopbreak().
908 event_base_loopbreak() is called, until the event loop is next entered.
911 @return true if event_base_loopbreak() was called on this event base,
920 * @name event flags
936 * Persistent event: won't get removed automatically when activated.
938 * When a persistent event with a timeout becomes activated, its timeout
946 * while waiting for the event callback to complete in another thread.
949 * event_free_finalize() in order to safely tear down an event in a
998 A callback function for an event.
1011 Return a value used to specify that the event itself must be used as the callback argument.
1014 to the event's callback function. To specify that the argument to be
1015 passed to the callback function is the event that event_new() returns,
1021 struct event *ev = event_new(base, sock, events, callback, %event_self_cbarg());
1026 achieves the same result as passing the event in directly.
1036 Allocate and asssign a new event structure, ready to be added.
1038 The function event_new() returns a new event that can be used in
1040 arguments determine which conditions will trigger the event; the
1042 event becomes active.
1049 event can be triggered only by a timeout or by manual activation with
1064 When the event becomes active, the event loop will run the provided
1069 event occurred. The third event will be the callback_arg pointer that
1072 @param base the event base to which the event should be attached.
1076 @param callback callback function to be invoked when the event occurs
1079 @return a newly allocated struct event that must later be freed with
1084 struct event *event_new(struct event_base *, evutil_socket_t, short, event_callback_fn, void *);
1088 Prepare a new, already-allocated event structure to be added.
1090 The function event_assign() prepares the event structure ev to be used
1093 allocated a struct event, probably on the heap. Doing this will
1094 typically make your code depend on the size of the event structure, and
1101 event_get_struct_event_size() to determine the required size of an event
1104 Note that it is NOT safe to call this function on an event that is
1107 event_assign to change an existing event, but only if it is not active
1113 @param ev an event struct to be modified
1114 @param base the event base to which ev should be attached.
1117 @param callback callback function to be invoked when the event occurs
1126 int event_assign(struct event *, struct event_base *, evutil_socket_t, short, event_callback_fn, void *);
1129 Deallocate a struct event * returned by event_new().
1131 If the event is pending or active, first make it non-pending and
1135 void event_free(struct event *);
1144 typedef void (*event_finalize_callback_fn)(struct event *, void *);
1148 These functions are used to safely tear down an event in a multithreaded
1150 deadlocks, you will need a way to remove an event in the certainty that
1155 0 for its first argument, the event to tear down as its second argument,
1157 invoked as part of the event loop, with the event's priority.
1160 no longer work on the event, and event_del() will produce a no-op. You
1161 must not try to change the event's fields with event_assign() or
1163 callback has been invoked, you should treat the event structure as
1166 The event_free_finalize() function frees the event after it's finalized;
1170 add events, activate events, or attempt to "resucitate" the event being
1180 int event_finalize(unsigned, struct event *, event_finalize_callback_fn);
1182 int event_free_finalize(unsigned, struct event *, event_finalize_callback_fn);
1186 Schedule a one-time event
1190 caller to prepare an event structure.
1192 Note that in Libevent 2.0 and earlier, if the event is never triggered, the
1194 the internal memory will get freed by event_base_free() if the event
1200 @param events event(s) to monitor; can be any of EV_READ |
1202 @param callback callback function to be invoked when the event occurs
1204 @param timeout the maximum amount of time to wait for the event. NULL
1205 makes an EV_READ/EV_WRITE event make forever; NULL makes an
1206 EV_TIMEOUT event succees immediately.
1213 Add an event to the set of pending events.
1215 The function event_add() schedules the execution of the event 'ev' when the
1219 called if a matching event occurs. The event in the
1224 If the event in the ev argument already has a scheduled timeout, calling
1227 @param ev an event struct initialized via event_assign() or event_new()
1228 @param timeout the maximum amount of time to wait for the event, or NULL
1234 int event_add(struct event *ev, const struct timeval *timeout);
1237 Remove a timer from a pending event without removing the event itself.
1239 If the event has a scheduled timeout, this function unschedules it but
1240 leaves the event otherwise pending.
1242 @param ev an event struct initialized via event_assign() or event_new()
1246 int event_remove_timer(struct event *ev);
1249 Remove an event from the set of monitored events.
1251 The function event_del() will cancel the event in the argument ev. If the
1252 event has already executed or has never been added the call will have no
1255 @param ev an event struct to be removed from the working set
1260 int event_del(struct event *);
1263 As event_del(), but never blocks while the event's callback is running
1264 in another thread, even if the event was constructed without the
1271 int event_del_noblock(struct event *ev);
1273 As event_del(), but always blocks while the event's callback is running
1274 in another thread, even if the event was constructed with the
1281 int event_del_block(struct event *ev);
1284 Make an event active.
1286 You can use this function on a pending or a non-pending event to make it
1293 @param ev an event to make active.
1294 @param res a set of flags to pass to the event's callback.
1298 void event_active(struct event *ev, int res, short ncalls);
1301 Checks if a specific event is pending or scheduled.
1303 @param ev an event struct previously passed to event_add()
1304 @param events the requested event type; any of EV_TIMEOUT|EV_READ|
1306 @param tv if this field is not NULL, and the event has a timeout,
1310 @return true if the event is pending on any of the events in 'what', (that
1311 is to say, it has been added), or 0 if the event is not added.
1314 int event_pending(const struct event *ev, short events, struct timeval *tv);
1317 If called from within the callback for an event, returns that event.
1320 callback function for an event.
1323 struct event *event_base_get_running_event(struct event_base *base);
1326 Test if an event structure might be initialized.
1328 The event_initialized() function can be used to check if an event has been
1332 piece of memory from an initialized event, it can easily be confused by
1334 initialized event from zero.
1336 @param ev an event structure to be tested
1341 int event_initialized(const struct event *ev);
1344 Get the signal number assigned to a signal event
1349 Get the socket or signal assigned to an event, or -1 if the event has
1353 evutil_socket_t event_get_fd(const struct event *ev);
1356 Get the event_base associated with an event.
1359 struct event_base *event_get_base(const struct event *ev);
1362 Return the events (EV_READ, EV_WRITE, etc) assigned to an event.
1365 short event_get_events(const struct event *ev);
1368 Return the callback assigned to an event.
1371 event_callback_fn event_get_callback(const struct event *ev);
1374 Return the callback argument assigned to an event.
1377 void *event_get_callback_arg(const struct event *ev);
1380 Return the priority of an event.
1384 int event_get_priority(const struct event *ev);
1387 Extract _all_ of arguments given to construct a given event. The
1394 void event_get_assignment(const struct event *event,
1399 Return the size of struct event that the Libevent library was compiled
1402 This will be NO GREATER than sizeof(struct event) if you're running with
1406 Note that it might be SMALLER than sizeof(struct event) if some future
1407 version of Libevent adds extra padding to the end of struct event.
1449 Set the number of different event priorities
1461 event. By default, Libevent assigns the middle priority to all events
1479 Get the number of different event priorities.
1482 @return Number of different event priorities
1489 Assign a priority to an event.
1491 @param ev an event struct
1497 int event_priority_set(struct event *, int);
1513 schedule the event more efficiently.
1570 Activates all pending events for the given fd and event mask.
1595 * Callback for iterating events in an event base via event_base_foreach_event
1597 typedef int (*event_base_foreach_event_cb)(const struct event_base *, const struct event *, void *);
1600 Iterate over all added or active events events in an event loop, and invoke
1603 The callback must not call any function that modifies the event base, that
1604 modifies any event in the event base, or that adds or removes any event to
1605 the event base. Doing so is unsupported and will lead to undefined
1621 @return 0 if we iterated over every event, or the value returned by the
1634 processing event callbacks, and may be very inaccuate if your
1650 * event loop, or if timeval caching is disabled via