… | |
… | |
126 | . ds Ae AE |
126 | . ds Ae AE |
127 | .\} |
127 | .\} |
128 | .rm #[ #] #H #V #F C |
128 | .rm #[ #] #H #V #F C |
129 | .\" ======================================================================== |
129 | .\" ======================================================================== |
130 | .\" |
130 | .\" |
131 | .IX Title ""<STANDARD INPUT>" 1" |
131 | .IX Title "EV 1" |
132 | .TH "<STANDARD INPUT>" 1 "2007-12-12" "perl v5.8.8" "User Contributed Perl Documentation" |
132 | .TH EV 1 "2007-12-19" "perl v5.8.8" "User Contributed Perl Documentation" |
133 | .SH "NAME" |
133 | .SH "NAME" |
134 | libev \- a high performance full\-featured event loop written in C |
134 | libev \- a high performance full\-featured event loop written in C |
135 | .SH "SYNOPSIS" |
135 | .SH "SYNOPSIS" |
136 | .IX Header "SYNOPSIS" |
136 | .IX Header "SYNOPSIS" |
137 | .Vb 1 |
137 | .Vb 1 |
… | |
… | |
243 | Libev represents time as a single floating point number, representing the |
243 | Libev represents time as a single floating point number, representing the |
244 | (fractional) number of seconds since the (\s-1POSIX\s0) epoch (somewhere near |
244 | (fractional) number of seconds since the (\s-1POSIX\s0) epoch (somewhere near |
245 | the beginning of 1970, details are complicated, don't ask). This type is |
245 | the beginning of 1970, details are complicated, don't ask). This type is |
246 | called \f(CW\*(C`ev_tstamp\*(C'\fR, which is what you should use too. It usually aliases |
246 | called \f(CW\*(C`ev_tstamp\*(C'\fR, which is what you should use too. It usually aliases |
247 | to the \f(CW\*(C`double\*(C'\fR type in C, and when you need to do any calculations on |
247 | to the \f(CW\*(C`double\*(C'\fR type in C, and when you need to do any calculations on |
248 | it, you should treat it as such. |
248 | it, you should treat it as some floatingpoint value. Unlike the name |
|
|
249 | component \f(CW\*(C`stamp\*(C'\fR might indicate, it is also used for time differences |
|
|
250 | throughout libev. |
249 | .SH "GLOBAL FUNCTIONS" |
251 | .SH "GLOBAL FUNCTIONS" |
250 | .IX Header "GLOBAL FUNCTIONS" |
252 | .IX Header "GLOBAL FUNCTIONS" |
251 | These functions can be called anytime, even before initialising the |
253 | These functions can be called anytime, even before initialising the |
252 | library in any way. |
254 | library in any way. |
253 | .IP "ev_tstamp ev_time ()" 4 |
255 | .IP "ev_tstamp ev_time ()" 4 |
… | |
… | |
555 | Destroys the default loop again (frees all memory and kernel state |
557 | Destroys the default loop again (frees all memory and kernel state |
556 | etc.). None of the active event watchers will be stopped in the normal |
558 | etc.). None of the active event watchers will be stopped in the normal |
557 | sense, so e.g. \f(CW\*(C`ev_is_active\*(C'\fR might still return true. It is your |
559 | sense, so e.g. \f(CW\*(C`ev_is_active\*(C'\fR might still return true. It is your |
558 | responsibility to either stop all watchers cleanly yoursef \fIbefore\fR |
560 | responsibility to either stop all watchers cleanly yoursef \fIbefore\fR |
559 | calling this function, or cope with the fact afterwards (which is usually |
561 | calling this function, or cope with the fact afterwards (which is usually |
560 | the easiest thing, youc na just ignore the watchers and/or \f(CW\*(C`free ()\*(C'\fR them |
562 | the easiest thing, you can just ignore the watchers and/or \f(CW\*(C`free ()\*(C'\fR them |
561 | for example). |
563 | for example). |
|
|
564 | .Sp |
|
|
565 | Not that certain global state, such as signal state, will not be freed by |
|
|
566 | this function, and related watchers (such as signal and child watchers) |
|
|
567 | would need to be stopped manually. |
|
|
568 | .Sp |
|
|
569 | In general it is not advisable to call this function except in the |
|
|
570 | rare occasion where you really need to free e.g. the signal handling |
|
|
571 | pipe fds. If you need dynamically allocated loops it is better to use |
|
|
572 | \&\f(CW\*(C`ev_loop_new\*(C'\fR and \f(CW\*(C`ev_loop_destroy\*(C'\fR). |
562 | .IP "ev_loop_destroy (loop)" 4 |
573 | .IP "ev_loop_destroy (loop)" 4 |
563 | .IX Item "ev_loop_destroy (loop)" |
574 | .IX Item "ev_loop_destroy (loop)" |
564 | Like \f(CW\*(C`ev_default_destroy\*(C'\fR, but destroys an event loop created by an |
575 | Like \f(CW\*(C`ev_default_destroy\*(C'\fR, but destroys an event loop created by an |
565 | earlier call to \f(CW\*(C`ev_loop_new\*(C'\fR. |
576 | earlier call to \f(CW\*(C`ev_loop_new\*(C'\fR. |
566 | .IP "ev_default_fork ()" 4 |
577 | .IP "ev_default_fork ()" 4 |
… | |
… | |
1379 | .IP "ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) [read\-write]" 4 |
1390 | .IP "ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) [read\-write]" 4 |
1380 | .IX Item "ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) [read-write]" |
1391 | .IX Item "ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now) [read-write]" |
1381 | The current reschedule callback, or \f(CW0\fR, if this functionality is |
1392 | The current reschedule callback, or \f(CW0\fR, if this functionality is |
1382 | switched off. Can be changed any time, but changes only take effect when |
1393 | switched off. Can be changed any time, but changes only take effect when |
1383 | the periodic timer fires or \f(CW\*(C`ev_periodic_again\*(C'\fR is being called. |
1394 | the periodic timer fires or \f(CW\*(C`ev_periodic_again\*(C'\fR is being called. |
|
|
1395 | .IP "ev_tstamp at [read\-only]" 4 |
|
|
1396 | .IX Item "ev_tstamp at [read-only]" |
|
|
1397 | When active, contains the absolute time that the watcher is supposed to |
|
|
1398 | trigger next. |
1384 | .PP |
1399 | .PP |
1385 | Example: Call a callback every hour, or, more precisely, whenever the |
1400 | Example: Call a callback every hour, or, more precisely, whenever the |
1386 | system clock is divisible by 3600. The callback invocation times have |
1401 | system clock is divisible by 3600. The callback invocation times have |
1387 | potentially a lot of jittering, but good long-term stability. |
1402 | potentially a lot of jittering, but good long-term stability. |
1388 | .PP |
1403 | .PP |
… | |
… | |
1993 | \&\f(CW\*(C`ev_default_fork\*(C'\fR or \f(CW\*(C`ev_loop_fork\*(C'\fR). The invocation is done before the |
2008 | \&\f(CW\*(C`ev_default_fork\*(C'\fR or \f(CW\*(C`ev_loop_fork\*(C'\fR). The invocation is done before the |
1994 | event loop blocks next and before \f(CW\*(C`ev_check\*(C'\fR watchers are being called, |
2009 | event loop blocks next and before \f(CW\*(C`ev_check\*(C'\fR watchers are being called, |
1995 | and only in the child after the fork. If whoever good citizen calling |
2010 | and only in the child after the fork. If whoever good citizen calling |
1996 | \&\f(CW\*(C`ev_default_fork\*(C'\fR cheats and calls it in the wrong process, the fork |
2011 | \&\f(CW\*(C`ev_default_fork\*(C'\fR cheats and calls it in the wrong process, the fork |
1997 | handlers will be invoked, too, of course. |
2012 | handlers will be invoked, too, of course. |
|
|
2013 | .PP |
|
|
2014 | \fIWatcher-Specific Functions and Data Members\fR |
|
|
2015 | .IX Subsection "Watcher-Specific Functions and Data Members" |
1998 | .IP "ev_fork_init (ev_signal *, callback)" 4 |
2016 | .IP "ev_fork_init (ev_signal *, callback)" 4 |
1999 | .IX Item "ev_fork_init (ev_signal *, callback)" |
2017 | .IX Item "ev_fork_init (ev_signal *, callback)" |
2000 | Initialises and configures the fork watcher \- it has no parameters of any |
2018 | Initialises and configures the fork watcher \- it has no parameters of any |
2001 | kind. There is a \f(CW\*(C`ev_fork_set\*(C'\fR macro, but using it is utterly pointless, |
2019 | kind. There is a \f(CW\*(C`ev_fork_set\*(C'\fR macro, but using it is utterly pointless, |
2002 | believe me. |
2020 | believe me. |
… | |
… | |
2196 | Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the |
2214 | Starts the watcher. Note that there is no \f(CW\*(C`loop\*(C'\fR argument, as the |
2197 | constructor already stores the event loop. |
2215 | constructor already stores the event loop. |
2198 | .IP "w\->stop ()" 4 |
2216 | .IP "w\->stop ()" 4 |
2199 | .IX Item "w->stop ()" |
2217 | .IX Item "w->stop ()" |
2200 | Stops the watcher if it is active. Again, no \f(CW\*(C`loop\*(C'\fR argument. |
2218 | Stops the watcher if it is active. Again, no \f(CW\*(C`loop\*(C'\fR argument. |
2201 | .ie n .IP "w\->again () ""ev::timer""\fR, \f(CW""ev::periodic"" only" 4 |
2219 | .ie n .IP "w\->again () (""ev::timer""\fR, \f(CW""ev::periodic"" only)" 4 |
2202 | .el .IP "w\->again () \f(CWev::timer\fR, \f(CWev::periodic\fR only" 4 |
2220 | .el .IP "w\->again () (\f(CWev::timer\fR, \f(CWev::periodic\fR only)" 4 |
2203 | .IX Item "w->again () ev::timer, ev::periodic only" |
2221 | .IX Item "w->again () (ev::timer, ev::periodic only)" |
2204 | For \f(CW\*(C`ev::timer\*(C'\fR and \f(CW\*(C`ev::periodic\*(C'\fR, this invokes the corresponding |
2222 | For \f(CW\*(C`ev::timer\*(C'\fR and \f(CW\*(C`ev::periodic\*(C'\fR, this invokes the corresponding |
2205 | \&\f(CW\*(C`ev_TYPE_again\*(C'\fR function. |
2223 | \&\f(CW\*(C`ev_TYPE_again\*(C'\fR function. |
2206 | .ie n .IP "w\->sweep () ""ev::embed"" only" 4 |
2224 | .ie n .IP "w\->sweep () (""ev::embed"" only)" 4 |
2207 | .el .IP "w\->sweep () \f(CWev::embed\fR only" 4 |
2225 | .el .IP "w\->sweep () (\f(CWev::embed\fR only)" 4 |
2208 | .IX Item "w->sweep () ev::embed only" |
2226 | .IX Item "w->sweep () (ev::embed only)" |
2209 | Invokes \f(CW\*(C`ev_embed_sweep\*(C'\fR. |
2227 | Invokes \f(CW\*(C`ev_embed_sweep\*(C'\fR. |
2210 | .ie n .IP "w\->update () ""ev::stat"" only" 4 |
2228 | .ie n .IP "w\->update () (""ev::stat"" only)" 4 |
2211 | .el .IP "w\->update () \f(CWev::stat\fR only" 4 |
2229 | .el .IP "w\->update () (\f(CWev::stat\fR only)" 4 |
2212 | .IX Item "w->update () ev::stat only" |
2230 | .IX Item "w->update () (ev::stat only)" |
2213 | Invokes \f(CW\*(C`ev_stat_stat\*(C'\fR. |
2231 | Invokes \f(CW\*(C`ev_stat_stat\*(C'\fR. |
2214 | .RE |
2232 | .RE |
2215 | .RS 4 |
2233 | .RS 4 |
2216 | .RE |
2234 | .RE |
2217 | .PP |
2235 | .PP |
… | |
… | |
2241 | \& io.start (fd, ev::READ); |
2259 | \& io.start (fd, ev::READ); |
2242 | \& } |
2260 | \& } |
2243 | .Ve |
2261 | .Ve |
2244 | .SH "MACRO MAGIC" |
2262 | .SH "MACRO MAGIC" |
2245 | .IX Header "MACRO MAGIC" |
2263 | .IX Header "MACRO MAGIC" |
2246 | Libev can be compiled with a variety of options, the most fundemantal is |
2264 | Libev can be compiled with a variety of options, the most fundamantal |
2247 | \&\f(CW\*(C`EV_MULTIPLICITY\*(C'\fR. This option determines whether (most) functions and |
2265 | of which is \f(CW\*(C`EV_MULTIPLICITY\*(C'\fR. This option determines whether (most) |
2248 | callbacks have an initial \f(CW\*(C`struct ev_loop *\*(C'\fR argument. |
2266 | functions and callbacks have an initial \f(CW\*(C`struct ev_loop *\*(C'\fR argument. |
2249 | .PP |
2267 | .PP |
2250 | To make it easier to write programs that cope with either variant, the |
2268 | To make it easier to write programs that cope with either variant, the |
2251 | following macros are defined: |
2269 | following macros are defined: |
2252 | .ie n .IP """EV_A""\fR, \f(CW""EV_A_""" 4 |
2270 | .ie n .IP """EV_A""\fR, \f(CW""EV_A_""" 4 |
2253 | .el .IP "\f(CWEV_A\fR, \f(CWEV_A_\fR" 4 |
2271 | .el .IP "\f(CWEV_A\fR, \f(CWEV_A_\fR" 4 |
… | |
… | |
2611 | and the way callbacks are invoked and set. Must expand to a struct member |
2629 | and the way callbacks are invoked and set. Must expand to a struct member |
2612 | definition and a statement, respectively. See the \fIev.v\fR header file for |
2630 | definition and a statement, respectively. See the \fIev.v\fR header file for |
2613 | their default definitions. One possible use for overriding these is to |
2631 | their default definitions. One possible use for overriding these is to |
2614 | avoid the \f(CW\*(C`struct ev_loop *\*(C'\fR as first argument in all cases, or to use |
2632 | avoid the \f(CW\*(C`struct ev_loop *\*(C'\fR as first argument in all cases, or to use |
2615 | method calls instead of plain function calls in \*(C+. |
2633 | method calls instead of plain function calls in \*(C+. |
|
|
2634 | .Sh "\s-1EXPORTED\s0 \s-1API\s0 \s-1SYMBOLS\s0" |
|
|
2635 | .IX Subsection "EXPORTED API SYMBOLS" |
|
|
2636 | If you need to re-export the \s-1API\s0 (e.g. via a dll) and you need a list of |
|
|
2637 | exported symbols, you can use the provided \fISymbol.*\fR files which list |
|
|
2638 | all public symbols, one per line: |
|
|
2639 | .Sp |
|
|
2640 | .Vb 2 |
|
|
2641 | \& Symbols.ev for libev proper |
|
|
2642 | \& Symbols.event for the libevent emulation |
|
|
2643 | .Ve |
|
|
2644 | .Sp |
|
|
2645 | This can also be used to rename all public symbols to avoid clashes with |
|
|
2646 | multiple versions of libev linked together (which is obviously bad in |
|
|
2647 | itself, but sometimes it is inconvinient to avoid this). |
|
|
2648 | .Sp |
|
|
2649 | A sed comamnd like this will create wrapper \f(CW\*(C`#define\*(C'\fR's that you need to |
|
|
2650 | include before including \fIev.h\fR: |
|
|
2651 | .Sp |
|
|
2652 | .Vb 1 |
|
|
2653 | \& <Symbols.ev sed -e "s/.*/#define & myprefix_&/" >wrap.h |
|
|
2654 | .Ve |
|
|
2655 | .Sp |
|
|
2656 | This would create a file \fIwrap.h\fR which essentially looks like this: |
|
|
2657 | .Sp |
|
|
2658 | .Vb 4 |
|
|
2659 | \& #define ev_backend myprefix_ev_backend |
|
|
2660 | \& #define ev_check_start myprefix_ev_check_start |
|
|
2661 | \& #define ev_check_stop myprefix_ev_check_stop |
|
|
2662 | \& ... |
|
|
2663 | .Ve |
2616 | .Sh "\s-1EXAMPLES\s0" |
2664 | .Sh "\s-1EXAMPLES\s0" |
2617 | .IX Subsection "EXAMPLES" |
2665 | .IX Subsection "EXAMPLES" |
2618 | For a real-world example of a program the includes libev |
2666 | For a real-world example of a program the includes libev |
2619 | verbatim, you can have a look at the \s-1EV\s0 perl module |
2667 | verbatim, you can have a look at the \s-1EV\s0 perl module |
2620 | (<http://software.schmorp.de/pkg/EV.html>). It has the libev files in |
2668 | (<http://software.schmorp.de/pkg/EV.html>). It has the libev files in |