libevent  2.2.1
Event notification library
watch.h
Go to the documentation of this file.
1 /*
2  * Redistribution and use in source and binary forms, with or without
3  * modification, are permitted provided that the following conditions
4  * are met:
5  * 1. Redistributions of source code must retain the above copyright
6  * notice, this list of conditions and the following disclaimer.
7  * 2. Redistributions in binary form must reproduce the above copyright
8  * notice, this list of conditions and the following disclaimer in the
9  * documentation and/or other materials provided with the distribution.
10  * 3. The name of the author may not be used to endorse or promote products
11  * derived from this software without specific prior written permission.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  */
24 #ifndef EVENT2_WATCH_H_INCLUDED_
25 #define EVENT2_WATCH_H_INCLUDED_
26 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #include <event2/visibility.h>
44 
45 struct event_base;
46 struct evwatch;
47 struct evwatch_prepare_cb_info;
48 struct evwatch_check_cb_info;
49 struct timeval;
50 
59 typedef void (*evwatch_prepare_cb)(struct evwatch *, const struct evwatch_prepare_cb_info *, void *);
60 
69 typedef void (*evwatch_check_cb)(struct evwatch *, const struct evwatch_check_cb_info *, void *);
70 
81 EVENT2_EXPORT_SYMBOL
82 struct evwatch *evwatch_prepare_new(struct event_base *base, evwatch_prepare_cb callback, void *arg);
83 
94 EVENT2_EXPORT_SYMBOL
95 struct evwatch *evwatch_check_new(struct event_base *base, evwatch_check_cb callback, void *arg);
96 
103 EVENT2_EXPORT_SYMBOL
104 struct event_base *evwatch_base(struct evwatch *watcher);
105 
114 EVENT2_EXPORT_SYMBOL
115 void evwatch_free(struct evwatch *watcher);
116 
129 EVENT2_EXPORT_SYMBOL
130 int evwatch_prepare_get_timeout(const struct evwatch_prepare_cb_info *info, struct timeval *timeout);
131 
132 #ifdef __cplusplus
133 }
134 #endif
135 
136 #endif /* EVENT2_WATCH_H_INCLUDED_ */
evwatch_base
EVENT2_EXPORT_SYMBOL struct event_base * evwatch_base(struct evwatch *watcher)
Get the event_base that a given evwatch is registered with.
evwatch_prepare_cb
void(* evwatch_prepare_cb)(struct evwatch *, const struct evwatch_prepare_cb_info *, void *)
Prepare callback, invoked by event_base_loop immediately before polling for I/O.
Definition: watch.h:59
evwatch_check_cb
void(* evwatch_check_cb)(struct evwatch *, const struct evwatch_check_cb_info *, void *)
Check callback, invoked by event_base_loop immediately after polling for I/O and before processing an...
Definition: watch.h:69
event_base
Structure to hold information and state for a Libevent dispatch loop.
Definition: event.h:219
evwatch_prepare_get_timeout
EVENT2_EXPORT_SYMBOL int evwatch_prepare_get_timeout(const struct evwatch_prepare_cb_info *info, struct timeval *timeout)
Get the timeout (the expected polling duration) passed to the underlying implementation's dispatch.
evwatch_check_new
EVENT2_EXPORT_SYMBOL struct evwatch * evwatch_check_new(struct event_base *base, evwatch_check_cb callback, void *arg)
Register a new "check" watcher, to be called in the event loop after polling for events and before ha...
evwatch_prepare_new
EVENT2_EXPORT_SYMBOL struct evwatch * evwatch_prepare_new(struct event_base *base, evwatch_prepare_cb callback, void *arg)
Register a new "prepare" watcher, to be called in the event loop prior to polling for events.
evwatch_free
EVENT2_EXPORT_SYMBOL void evwatch_free(struct evwatch *watcher)
Deregister and deallocate a watcher.