… | |
… | |
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-18" "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 |
… | |
… | |
2199 | 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 |
2200 | constructor already stores the event loop. |
2215 | constructor already stores the event loop. |
2201 | .IP "w\->stop ()" 4 |
2216 | .IP "w\->stop ()" 4 |
2202 | .IX Item "w->stop ()" |
2217 | .IX Item "w->stop ()" |
2203 | 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. |
2204 | .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 |
2205 | .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 |
2206 | .IX Item "w->again () ev::timer, ev::periodic only" |
2221 | .IX Item "w->again () (ev::timer, ev::periodic only)" |
2207 | 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 |
2208 | \&\f(CW\*(C`ev_TYPE_again\*(C'\fR function. |
2223 | \&\f(CW\*(C`ev_TYPE_again\*(C'\fR function. |
2209 | .ie n .IP "w\->sweep () ""ev::embed"" only" 4 |
2224 | .ie n .IP "w\->sweep () (""ev::embed"" only)" 4 |
2210 | .el .IP "w\->sweep () \f(CWev::embed\fR only" 4 |
2225 | .el .IP "w\->sweep () (\f(CWev::embed\fR only)" 4 |
2211 | .IX Item "w->sweep () ev::embed only" |
2226 | .IX Item "w->sweep () (ev::embed only)" |
2212 | Invokes \f(CW\*(C`ev_embed_sweep\*(C'\fR. |
2227 | Invokes \f(CW\*(C`ev_embed_sweep\*(C'\fR. |
2213 | .ie n .IP "w\->update () ""ev::stat"" only" 4 |
2228 | .ie n .IP "w\->update () (""ev::stat"" only)" 4 |
2214 | .el .IP "w\->update () \f(CWev::stat\fR only" 4 |
2229 | .el .IP "w\->update () (\f(CWev::stat\fR only)" 4 |
2215 | .IX Item "w->update () ev::stat only" |
2230 | .IX Item "w->update () (ev::stat only)" |
2216 | Invokes \f(CW\*(C`ev_stat_stat\*(C'\fR. |
2231 | Invokes \f(CW\*(C`ev_stat_stat\*(C'\fR. |
2217 | .RE |
2232 | .RE |
2218 | .RS 4 |
2233 | .RS 4 |
2219 | .RE |
2234 | .RE |
2220 | .PP |
2235 | .PP |
… | |
… | |
2244 | \& io.start (fd, ev::READ); |
2259 | \& io.start (fd, ev::READ); |
2245 | \& } |
2260 | \& } |
2246 | .Ve |
2261 | .Ve |
2247 | .SH "MACRO MAGIC" |
2262 | .SH "MACRO MAGIC" |
2248 | .IX Header "MACRO MAGIC" |
2263 | .IX Header "MACRO MAGIC" |
2249 | 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 |
2250 | \&\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) |
2251 | 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. |
2252 | .PP |
2267 | .PP |
2253 | 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 |
2254 | following macros are defined: |
2269 | following macros are defined: |
2255 | .ie n .IP """EV_A""\fR, \f(CW""EV_A_""" 4 |
2270 | .ie n .IP """EV_A""\fR, \f(CW""EV_A_""" 4 |
2256 | .el .IP "\f(CWEV_A\fR, \f(CWEV_A_\fR" 4 |
2271 | .el .IP "\f(CWEV_A\fR, \f(CWEV_A_\fR" 4 |