Hash :
620a3fa1
Author :
Date :
2019-08-29T19:40:10
Doxygen documentation improvements - Documentation for `bufferevent_compat.h` and `rpc.h` is not generated since the `@file` command is missing. It can be fixed by adding `@file` in file comment block. - The briefs of buffer.h,bufferevent.h and some other files are missing. Adding `@brief` command can fix it. - The parameters in the function declaration are different from the parameters following the `@param` command.We should change them to the same. - Documentation of `watch.h` is not generated since `watch.h` has not been added to the Doxyfile `INPUT` tag. - Add link to the watch.h in event.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EVENT2_WATCH_H_INCLUDED_
#define EVENT2_WATCH_H_INCLUDED_
/** @file event2/watch.h
@brief "Prepare" and "check" watchers.
"Prepare" and "check" watchers. A "prepare" watcher is a callback that fires
immediately before polling for I/O. A "check" watcher is a callback that
fires immediately after polling and before processing any active events. This
may be useful for embedding other libraries' event loops (e.g. UI toolkits)
into libevent's.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <event2/visibility.h>
struct event_base;
struct evwatch;
struct evwatch_prepare_cb_info;
struct evwatch_check_cb_info;
struct timeval;
/**
Prepare callback, invoked by event_base_loop immediately before polling for
I/O.
@param watcher the prepare watcher that invoked this callback.
@param info contextual information passed from event_base_loop.
@param arg additional user-defined argument, set in `evwatch_prepare_new`.
*/
typedef void (*evwatch_prepare_cb)(struct evwatch *, const struct evwatch_prepare_cb_info *, void *);
/**
Check callback, invoked by event_base_loop immediately after polling for I/O
and before processing any active events.
@param watcher the check watcher that invoked this callback.
@param info contextual information passed from event_base_loop.
@param arg additional user-defined argument, set in `evwatch_check_new`.
*/
typedef void (*evwatch_check_cb)(struct evwatch *, const struct evwatch_check_cb_info *, void *);
/**
Register a new "prepare" watcher, to be called in the event loop prior to
polling for events. Watchers will be called in the order they were
registered.
@param base the event_base to operate on.
@param callback the callback function to invoke.
@param arg additional user-defined argument provided to the callback.
@return a pointer to the newly allocated event watcher.
*/
EVENT2_EXPORT_SYMBOL
struct evwatch *evwatch_prepare_new(struct event_base *base, evwatch_prepare_cb callback, void *arg);
/**
Register a new "check" watcher, to be called in the event loop after polling
for events and before handling them. Watchers will be called in the order
they were registered.
@param base the event_base to operate on.
@param callback the callback function to invoke.
@param arg additional user-defined argument provided to the callback.
@return a pointer to the newly allocated event watcher.
*/
EVENT2_EXPORT_SYMBOL
struct evwatch *evwatch_check_new(struct event_base *base, evwatch_check_cb callback, void *arg);
/**
Get the event_base that a given evwatch is registered with.
@param watcher the watcher to get the event_base for.
@return the event_base for the given watcher.
*/
EVENT2_EXPORT_SYMBOL
struct event_base *evwatch_base(struct evwatch *watcher);
/**
Deregister and deallocate a watcher. Any watchers not freed using
evwatch_free will eventually be deallocated in event_base_free
(calling evwatch_free on a watcher after event_base_free has been
called on its corresponding event_base is an error).
@param watcher the watcher to deregister and deallocate.
*/
EVENT2_EXPORT_SYMBOL
void evwatch_free(struct evwatch *watcher);
/**
Get the timeout (the expected polling duration) passed to the underlying
implementation's `dispatch`. This value will only be set if there are pending
EV_TIMEOUT events and if the event_base isn't in EVLOOP_NONBLOCK mode. It may
be a useful performance statistic to compare the expected polling duration
against the actual polling duration (that is, the time difference measured
between this prepare callback and the following check callback).
@param info the "prepare" callback info.
@param timeout address of a timeval to write the polling duration to.
@return 1 if a value was written to *timeout, or 0 if not.
*/
EVENT2_EXPORT_SYMBOL
int evwatch_prepare_get_timeout(const struct evwatch_prepare_cb_info *info, struct timeval *timeout);
#ifdef __cplusplus
}
#endif
#endif /* EVENT2_WATCH_H_INCLUDED_ */