… | |
… | |
130 | .\} |
130 | .\} |
131 | .rm #[ #] #H #V #F C |
131 | .rm #[ #] #H #V #F C |
132 | .\" ======================================================================== |
132 | .\" ======================================================================== |
133 | .\" |
133 | .\" |
134 | .IX Title "LIBEV 3" |
134 | .IX Title "LIBEV 3" |
135 | .TH LIBEV 3 "2008-10-30" "libev-3.48" "libev - high performance full featured event loop" |
135 | .TH LIBEV 3 "2009-02-06" "libev-3.53" "libev - high performance full featured event loop" |
136 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
136 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
137 | .\" way too many mistakes in technical documents. |
137 | .\" way too many mistakes in technical documents. |
138 | .if n .ad l |
138 | .if n .ad l |
139 | .nh |
139 | .nh |
140 | .SH "NAME" |
140 | .SH "NAME" |
… | |
… | |
148 | .IX Subsection "EXAMPLE PROGRAM" |
148 | .IX Subsection "EXAMPLE PROGRAM" |
149 | .Vb 2 |
149 | .Vb 2 |
150 | \& // a single header file is required |
150 | \& // a single header file is required |
151 | \& #include <ev.h> |
151 | \& #include <ev.h> |
152 | \& |
152 | \& |
|
|
153 | \& #include <stdio.h> // for puts |
|
|
154 | \& |
153 | \& // every watcher type has its own typedef\*(Aqd struct |
155 | \& // every watcher type has its own typedef\*(Aqd struct |
154 | \& // with the name ev_TYPE |
156 | \& // with the name ev_TYPE |
155 | \& ev_io stdin_watcher; |
157 | \& ev_io stdin_watcher; |
156 | \& ev_timer timeout_watcher; |
158 | \& ev_timer timeout_watcher; |
157 | \& |
159 | \& |
… | |
… | |
180 | \& |
182 | \& |
181 | \& int |
183 | \& int |
182 | \& main (void) |
184 | \& main (void) |
183 | \& { |
185 | \& { |
184 | \& // use the default event loop unless you have special needs |
186 | \& // use the default event loop unless you have special needs |
185 | \& ev_loop *loop = ev_default_loop (0); |
187 | \& struct ev_loop *loop = ev_default_loop (0); |
186 | \& |
188 | \& |
187 | \& // initialise an io watcher, then start it |
189 | \& // initialise an io watcher, then start it |
188 | \& // this one will watch for stdin to become readable |
190 | \& // this one will watch for stdin to become readable |
189 | \& ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); |
191 | \& ev_io_init (&stdin_watcher, stdin_cb, /*STDIN_FILENO*/ 0, EV_READ); |
190 | \& ev_io_start (loop, &stdin_watcher); |
192 | \& ev_io_start (loop, &stdin_watcher); |
… | |
… | |
544 | starting a watcher (without re-setting it) also usually doesn't cause |
546 | starting a watcher (without re-setting it) also usually doesn't cause |
545 | extra overhead. A fork can both result in spurious notifications as well |
547 | extra overhead. A fork can both result in spurious notifications as well |
546 | as in libev having to destroy and recreate the epoll object, which can |
548 | as in libev having to destroy and recreate the epoll object, which can |
547 | take considerable time and thus should be avoided. |
549 | take considerable time and thus should be avoided. |
548 | .Sp |
550 | .Sp |
|
|
551 | All this means that, in practice, \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR can be as fast or |
|
|
552 | faster than epoll for maybe up to a hundred file descriptors, depending on |
|
|
553 | the usage. So sad. |
|
|
554 | .Sp |
549 | While nominally embeddable in other event loops, this feature is broken in |
555 | While nominally embeddable in other event loops, this feature is broken in |
550 | all kernel versions tested so far. |
556 | all kernel versions tested so far. |
551 | .Sp |
557 | .Sp |
552 | This backend maps \f(CW\*(C`EV_READ\*(C'\fR and \f(CW\*(C`EV_WRITE\*(C'\fR in the same way as |
558 | This backend maps \f(CW\*(C`EV_READ\*(C'\fR and \f(CW\*(C`EV_WRITE\*(C'\fR in the same way as |
553 | \&\f(CW\*(C`EVBACKEND_POLL\*(C'\fR. |
559 | \&\f(CW\*(C`EVBACKEND_POLL\*(C'\fR. |
… | |
… | |
580 | .Sp |
586 | .Sp |
581 | While nominally embeddable in other event loops, this doesn't work |
587 | While nominally embeddable in other event loops, this doesn't work |
582 | everywhere, so you might need to test for this. And since it is broken |
588 | everywhere, so you might need to test for this. And since it is broken |
583 | almost everywhere, you should only use it when you have a lot of sockets |
589 | almost everywhere, you should only use it when you have a lot of sockets |
584 | (for which it usually works), by embedding it into another event loop |
590 | (for which it usually works), by embedding it into another event loop |
585 | (e.g. \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR) and, did I mention it, |
591 | (e.g. \f(CW\*(C`EVBACKEND_SELECT\*(C'\fR or \f(CW\*(C`EVBACKEND_POLL\*(C'\fR (but \f(CW\*(C`poll\*(C'\fR is of course |
586 | using it only for sockets. |
592 | also broken on \s-1OS\s0 X)) and, did I mention it, using it only for sockets. |
587 | .Sp |
593 | .Sp |
588 | This backend maps \f(CW\*(C`EV_READ\*(C'\fR into an \f(CW\*(C`EVFILT_READ\*(C'\fR kevent with |
594 | This backend maps \f(CW\*(C`EV_READ\*(C'\fR into an \f(CW\*(C`EVFILT_READ\*(C'\fR kevent with |
589 | \&\f(CW\*(C`NOTE_EOF\*(C'\fR, and \f(CW\*(C`EV_WRITE\*(C'\fR into an \f(CW\*(C`EVFILT_WRITE\*(C'\fR kevent with |
595 | \&\f(CW\*(C`NOTE_EOF\*(C'\fR, and \f(CW\*(C`EV_WRITE\*(C'\fR into an \f(CW\*(C`EVFILT_WRITE\*(C'\fR kevent with |
590 | \&\f(CW\*(C`NOTE_EOF\*(C'\fR. |
596 | \&\f(CW\*(C`NOTE_EOF\*(C'\fR. |
591 | .ie n .IP """EVBACKEND_DEVPOLL"" (value 16, Solaris 8)" 4 |
597 | .ie n .IP """EVBACKEND_DEVPOLL"" (value 16, Solaris 8)" 4 |
… | |
… | |
1557 | \& else |
1563 | \& else |
1558 | \& { |
1564 | \& { |
1559 | \& // callback was invoked, but there was some activity, re\-arm |
1565 | \& // callback was invoked, but there was some activity, re\-arm |
1560 | \& // the watcher to fire in last_activity + 60, which is |
1566 | \& // the watcher to fire in last_activity + 60, which is |
1561 | \& // guaranteed to be in the future, so "again" is positive: |
1567 | \& // guaranteed to be in the future, so "again" is positive: |
1562 | \& w\->again = timeout \- now; |
1568 | \& w\->repeat = timeout \- now; |
1563 | \& ev_timer_again (EV_A_ w); |
1569 | \& ev_timer_again (EV_A_ w); |
1564 | \& } |
1570 | \& } |
1565 | \& } |
1571 | \& } |
1566 | .Ve |
1572 | .Ve |
1567 | .Sp |
1573 | .Sp |
… | |
… | |
2081 | \&\f(CW\*(C`stat\*(C'\fR on that path in regular intervals (or when the \s-1OS\s0 says it changed) |
2087 | \&\f(CW\*(C`stat\*(C'\fR on that path in regular intervals (or when the \s-1OS\s0 says it changed) |
2082 | and sees if it changed compared to the last time, invoking the callback if |
2088 | and sees if it changed compared to the last time, invoking the callback if |
2083 | it did. |
2089 | it did. |
2084 | .PP |
2090 | .PP |
2085 | The path does not need to exist: changing from \*(L"path exists\*(R" to \*(L"path does |
2091 | The path does not need to exist: changing from \*(L"path exists\*(R" to \*(L"path does |
2086 | not exist\*(R" is a status change like any other. The condition \*(L"path does |
2092 | not exist\*(R" is a status change like any other. The condition \*(L"path does not |
2087 | not exist\*(R" is signified by the \f(CW\*(C`st_nlink\*(C'\fR field being zero (which is |
2093 | exist\*(R" (or more correctly \*(L"path cannot be stat'ed\*(R") is signified by the |
2088 | otherwise always forced to be at least one) and all the other fields of |
2094 | \&\f(CW\*(C`st_nlink\*(C'\fR field being zero (which is otherwise always forced to be at |
2089 | the stat buffer having unspecified contents. |
2095 | least one) and all the other fields of the stat buffer having unspecified |
|
|
2096 | contents. |
2090 | .PP |
2097 | .PP |
2091 | The path \fImust not\fR end in a slash or contain special components such as |
2098 | The path \fImust not\fR end in a slash or contain special components such as |
2092 | \&\f(CW\*(C`.\*(C'\fR or \f(CW\*(C`..\*(C'\fR. The path \fIshould\fR be absolute: If it is relative and |
2099 | \&\f(CW\*(C`.\*(C'\fR or \f(CW\*(C`..\*(C'\fR. The path \fIshould\fR be absolute: If it is relative and |
2093 | your working directory changes, then the behaviour is undefined. |
2100 | your working directory changes, then the behaviour is undefined. |
2094 | .PP |
2101 | .PP |
… | |
… | |
2104 | This watcher type is not meant for massive numbers of stat watchers, |
2111 | This watcher type is not meant for massive numbers of stat watchers, |
2105 | as even with OS-supported change notifications, this can be |
2112 | as even with OS-supported change notifications, this can be |
2106 | resource-intensive. |
2113 | resource-intensive. |
2107 | .PP |
2114 | .PP |
2108 | At the time of this writing, the only OS-specific interface implemented |
2115 | At the time of this writing, the only OS-specific interface implemented |
2109 | is the Linux inotify interface (implementing kqueue support is left as |
2116 | is the Linux inotify interface (implementing kqueue support is left as an |
2110 | an exercise for the reader. Note, however, that the author sees no way |
2117 | exercise for the reader. Note, however, that the author sees no way of |
2111 | of implementing \f(CW\*(C`ev_stat\*(C'\fR semantics with kqueue). |
2118 | implementing \f(CW\*(C`ev_stat\*(C'\fR semantics with kqueue, except as a hint). |
2112 | .PP |
2119 | .PP |
2113 | \fI\s-1ABI\s0 Issues (Largefile Support)\fR |
2120 | \fI\s-1ABI\s0 Issues (Largefile Support)\fR |
2114 | .IX Subsection "ABI Issues (Largefile Support)" |
2121 | .IX Subsection "ABI Issues (Largefile Support)" |
2115 | .PP |
2122 | .PP |
2116 | Libev by default (unless the user overrides this) uses the default |
2123 | Libev by default (unless the user overrides this) uses the default |
… | |
… | |
2129 | default compilation environment. |
2136 | default compilation environment. |
2130 | .PP |
2137 | .PP |
2131 | \fIInotify and Kqueue\fR |
2138 | \fIInotify and Kqueue\fR |
2132 | .IX Subsection "Inotify and Kqueue" |
2139 | .IX Subsection "Inotify and Kqueue" |
2133 | .PP |
2140 | .PP |
2134 | When \f(CW\*(C`inotify (7)\*(C'\fR support has been compiled into libev (generally |
2141 | When \f(CW\*(C`inotify (7)\*(C'\fR support has been compiled into libev and present at |
2135 | only available with Linux 2.6.25 or above due to bugs in earlier |
2142 | runtime, it will be used to speed up change detection where possible. The |
2136 | implementations) and present at runtime, it will be used to speed up |
2143 | inotify descriptor will be created lazily when the first \f(CW\*(C`ev_stat\*(C'\fR |
2137 | change detection where possible. The inotify descriptor will be created |
2144 | watcher is being started. |
2138 | lazily when the first \f(CW\*(C`ev_stat\*(C'\fR watcher is being started. |
|
|
2139 | .PP |
2145 | .PP |
2140 | Inotify presence does not change the semantics of \f(CW\*(C`ev_stat\*(C'\fR watchers |
2146 | Inotify presence does not change the semantics of \f(CW\*(C`ev_stat\*(C'\fR watchers |
2141 | except that changes might be detected earlier, and in some cases, to avoid |
2147 | except that changes might be detected earlier, and in some cases, to avoid |
2142 | making regular \f(CW\*(C`stat\*(C'\fR calls. Even in the presence of inotify support |
2148 | making regular \f(CW\*(C`stat\*(C'\fR calls. Even in the presence of inotify support |
2143 | there are many cases where libev has to resort to regular \f(CW\*(C`stat\*(C'\fR polling, |
2149 | there are many cases where libev has to resort to regular \f(CW\*(C`stat\*(C'\fR polling, |
2144 | but as long as the path exists, libev usually gets away without polling. |
2150 | but as long as kernel 2.6.25 or newer is used (2.6.24 and older have too |
|
|
2151 | many bugs), the path exists (i.e. stat succeeds), and the path resides on |
|
|
2152 | a local filesystem (libev currently assumes only ext2/3, jfs, reiserfs and |
|
|
2153 | xfs are fully working) libev usually gets away without polling. |
2145 | .PP |
2154 | .PP |
2146 | There is no support for kqueue, as apparently it cannot be used to |
2155 | There is no support for kqueue, as apparently it cannot be used to |
2147 | implement this functionality, due to the requirement of having a file |
2156 | implement this functionality, due to the requirement of having a file |
2148 | descriptor open on the object at all times, and detecting renames, unlinks |
2157 | descriptor open on the object at all times, and detecting renames, unlinks |
2149 | etc. is difficult. |
2158 | etc. is difficult. |
|
|
2159 | .PP |
|
|
2160 | \fI\f(CI\*(C`stat ()\*(C'\fI is a synchronous operation\fR |
|
|
2161 | .IX Subsection "stat () is a synchronous operation" |
|
|
2162 | .PP |
|
|
2163 | Libev doesn't normally do any kind of I/O itself, and so is not blocking |
|
|
2164 | the process. The exception are \f(CW\*(C`ev_stat\*(C'\fR watchers \- those call \f(CW\*(C`stat |
|
|
2165 | ()\*(C'\fR, which is a synchronous operation. |
|
|
2166 | .PP |
|
|
2167 | For local paths, this usually doesn't matter: unless the system is very |
|
|
2168 | busy or the intervals between stat's are large, a stat call will be fast, |
|
|
2169 | as the path data is usually in memory already (except when starting the |
|
|
2170 | watcher). |
|
|
2171 | .PP |
|
|
2172 | For networked file systems, calling \f(CW\*(C`stat ()\*(C'\fR can block an indefinite |
|
|
2173 | time due to network issues, and even under good conditions, a stat call |
|
|
2174 | often takes multiple milliseconds. |
|
|
2175 | .PP |
|
|
2176 | Therefore, it is best to avoid using \f(CW\*(C`ev_stat\*(C'\fR watchers on networked |
|
|
2177 | paths, although this is fully supported by libev. |
2150 | .PP |
2178 | .PP |
2151 | \fIThe special problem of stat time resolution\fR |
2179 | \fIThe special problem of stat time resolution\fR |
2152 | .IX Subsection "The special problem of stat time resolution" |
2180 | .IX Subsection "The special problem of stat time resolution" |
2153 | .PP |
2181 | .PP |
2154 | The \f(CW\*(C`stat ()\*(C'\fR system call only supports full-second resolution portably, |
2182 | The \f(CW\*(C`stat ()\*(C'\fR system call only supports full-second resolution portably, |
… | |
… | |
2552 | some fds have to be watched and handled very quickly (with low latency), |
2580 | some fds have to be watched and handled very quickly (with low latency), |
2553 | and even priorities and idle watchers might have too much overhead. In |
2581 | and even priorities and idle watchers might have too much overhead. In |
2554 | this case you would put all the high priority stuff in one loop and all |
2582 | this case you would put all the high priority stuff in one loop and all |
2555 | the rest in a second one, and embed the second one in the first. |
2583 | the rest in a second one, and embed the second one in the first. |
2556 | .PP |
2584 | .PP |
2557 | As long as the watcher is active, the callback will be invoked every time |
2585 | As long as the watcher is active, the callback will be invoked every |
2558 | there might be events pending in the embedded loop. The callback must then |
2586 | time there might be events pending in the embedded loop. The callback |
2559 | call \f(CW\*(C`ev_embed_sweep (mainloop, watcher)\*(C'\fR to make a single sweep and invoke |
2587 | must then call \f(CW\*(C`ev_embed_sweep (mainloop, watcher)\*(C'\fR to make a single |
2560 | their callbacks (you could also start an idle watcher to give the embedded |
2588 | sweep and invoke their callbacks (the callback doesn't need to invoke the |
2561 | loop strictly lower priority for example). You can also set the callback |
2589 | \&\f(CW\*(C`ev_embed_sweep\*(C'\fR function directly, it could also start an idle watcher |
2562 | to \f(CW0\fR, in which case the embed watcher will automatically execute the |
2590 | to give the embedded loop strictly lower priority for example). |
2563 | embedded loop sweep. |
|
|
2564 | .PP |
2591 | .PP |
2565 | As long as the watcher is started it will automatically handle events. The |
2592 | You can also set the callback to \f(CW0\fR, in which case the embed watcher |
2566 | callback will be invoked whenever some events have been handled. You can |
2593 | will automatically execute the embedded loop sweep whenever necessary. |
2567 | set the callback to \f(CW0\fR to avoid having to specify one if you are not |
|
|
2568 | interested in that. |
|
|
2569 | .PP |
2594 | .PP |
2570 | Also, there have not currently been made special provisions for forking: |
2595 | Fork detection will be handled transparently while the \f(CW\*(C`ev_embed\*(C'\fR watcher |
2571 | when you fork, you not only have to call \f(CW\*(C`ev_loop_fork\*(C'\fR on both loops, |
2596 | is active, i.e., the embedded loop will automatically be forked when the |
2572 | but you will also have to stop and restart any \f(CW\*(C`ev_embed\*(C'\fR watchers |
2597 | embedding loop forks. In other cases, the user is responsible for calling |
2573 | yourself \- but you can use a fork watcher to handle this automatically, |
2598 | \&\f(CW\*(C`ev_loop_fork\*(C'\fR on the embedded loop. |
2574 | and future versions of libev might do just that. |
|
|
2575 | .PP |
2599 | .PP |
2576 | Unfortunately, not all backends are embeddable: only the ones returned by |
2600 | Unfortunately, not all backends are embeddable: only the ones returned by |
2577 | \&\f(CW\*(C`ev_embeddable_backends\*(C'\fR are, which, unfortunately, does not include any |
2601 | \&\f(CW\*(C`ev_embeddable_backends\*(C'\fR are, which, unfortunately, does not include any |
2578 | portable one. |
2602 | portable one. |
2579 | .PP |
2603 | .PP |
… | |
… | |
2988 | \& |
3012 | \& |
2989 | \& myclass obj; |
3013 | \& myclass obj; |
2990 | \& ev::io iow; |
3014 | \& ev::io iow; |
2991 | \& iow.set <myclass, &myclass::io_cb> (&obj); |
3015 | \& iow.set <myclass, &myclass::io_cb> (&obj); |
2992 | .Ve |
3016 | .Ve |
|
|
3017 | .IP "w\->set (object *)" 4 |
|
|
3018 | .IX Item "w->set (object *)" |
|
|
3019 | This is an \fBexperimental\fR feature that might go away in a future version. |
|
|
3020 | .Sp |
|
|
3021 | This is a variation of a method callback \- leaving out the method to call |
|
|
3022 | will default the method to \f(CW\*(C`operator ()\*(C'\fR, which makes it possible to use |
|
|
3023 | functor objects without having to manually specify the \f(CW\*(C`operator ()\*(C'\fR all |
|
|
3024 | the time. Incidentally, you can then also leave out the template argument |
|
|
3025 | list. |
|
|
3026 | .Sp |
|
|
3027 | The \f(CW\*(C`operator ()\*(C'\fR method prototype must be \f(CW\*(C`void operator ()(watcher &w, |
|
|
3028 | int revents)\*(C'\fR. |
|
|
3029 | .Sp |
|
|
3030 | See the method\-\f(CW\*(C`set\*(C'\fR above for more details. |
|
|
3031 | .Sp |
|
|
3032 | Example: use a functor object as callback. |
|
|
3033 | .Sp |
|
|
3034 | .Vb 7 |
|
|
3035 | \& struct myfunctor |
|
|
3036 | \& { |
|
|
3037 | \& void operator() (ev::io &w, int revents) |
|
|
3038 | \& { |
|
|
3039 | \& ... |
|
|
3040 | \& } |
|
|
3041 | \& } |
|
|
3042 | \& |
|
|
3043 | \& myfunctor f; |
|
|
3044 | \& |
|
|
3045 | \& ev::io w; |
|
|
3046 | \& w.set (&f); |
|
|
3047 | .Ve |
2993 | .IP "w\->set<function> (void *data = 0)" 4 |
3048 | .IP "w\->set<function> (void *data = 0)" 4 |
2994 | .IX Item "w->set<function> (void *data = 0)" |
3049 | .IX Item "w->set<function> (void *data = 0)" |
2995 | Also sets a callback, but uses a static method or plain function as |
3050 | Also sets a callback, but uses a static method or plain function as |
2996 | callback. The optional \f(CW\*(C`data\*(C'\fR argument will be stored in the watcher's |
3051 | callback. The optional \f(CW\*(C`data\*(C'\fR argument will be stored in the watcher's |
2997 | \&\f(CW\*(C`data\*(C'\fR member and is free for you to use. |
3052 | \&\f(CW\*(C`data\*(C'\fR member and is free for you to use. |
… | |
… | |
3087 | .IX Item "Ruby" |
3142 | .IX Item "Ruby" |
3088 | Tony Arcieri has written a ruby extension that offers access to a subset |
3143 | Tony Arcieri has written a ruby extension that offers access to a subset |
3089 | of the libev \s-1API\s0 and adds file handle abstractions, asynchronous \s-1DNS\s0 and |
3144 | of the libev \s-1API\s0 and adds file handle abstractions, asynchronous \s-1DNS\s0 and |
3090 | more on top of it. It can be found via gem servers. Its homepage is at |
3145 | more on top of it. It can be found via gem servers. Its homepage is at |
3091 | <http://rev.rubyforge.org/>. |
3146 | <http://rev.rubyforge.org/>. |
|
|
3147 | .Sp |
|
|
3148 | Roger Pack reports that using the link order \f(CW\*(C`\-lws2_32 \-lmsvcrt\-ruby\-190\*(C'\fR |
|
|
3149 | makes rev work even on mingw. |
3092 | .IP "D" 4 |
3150 | .IP "D" 4 |
3093 | .IX Item "D" |
3151 | .IX Item "D" |
3094 | Leandro Lucarella has written a D language binding (\fIev.d\fR) for libev, to |
3152 | Leandro Lucarella has written a D language binding (\fIev.d\fR) for libev, to |
3095 | be found at <http://proj.llucax.com.ar/wiki/evd>. |
3153 | be found at <http://proj.llucax.com.ar/wiki/evd>. |
3096 | .IP "Ocaml" 4 |
3154 | .IP "Ocaml" 4 |
… | |
… | |
3279 | Must always be \f(CW1\fR if you do not use autoconf configuration, which |
3337 | Must always be \f(CW1\fR if you do not use autoconf configuration, which |
3280 | keeps libev from including \fIconfig.h\fR, and it also defines dummy |
3338 | keeps libev from including \fIconfig.h\fR, and it also defines dummy |
3281 | implementations for some libevent functions (such as logging, which is not |
3339 | implementations for some libevent functions (such as logging, which is not |
3282 | supported). It will also not define any of the structs usually found in |
3340 | supported). It will also not define any of the structs usually found in |
3283 | \&\fIevent.h\fR that are not directly supported by the libev core alone. |
3341 | \&\fIevent.h\fR that are not directly supported by the libev core alone. |
|
|
3342 | .Sp |
|
|
3343 | In stanbdalone mode, libev will still try to automatically deduce the |
|
|
3344 | configuration, but has to be more conservative. |
3284 | .IP "\s-1EV_USE_MONOTONIC\s0" 4 |
3345 | .IP "\s-1EV_USE_MONOTONIC\s0" 4 |
3285 | .IX Item "EV_USE_MONOTONIC" |
3346 | .IX Item "EV_USE_MONOTONIC" |
3286 | If defined to be \f(CW1\fR, libev will try to detect the availability of the |
3347 | If defined to be \f(CW1\fR, libev will try to detect the availability of the |
3287 | monotonic clock option at both compile time and runtime. Otherwise no use |
3348 | monotonic clock option at both compile time and runtime. Otherwise no |
3288 | of the monotonic clock option will be attempted. If you enable this, you |
3349 | use of the monotonic clock option will be attempted. If you enable this, |
3289 | usually have to link against librt or something similar. Enabling it when |
3350 | you usually have to link against librt or something similar. Enabling it |
3290 | the functionality isn't available is safe, though, although you have |
3351 | when the functionality isn't available is safe, though, although you have |
3291 | to make sure you link against any libraries where the \f(CW\*(C`clock_gettime\*(C'\fR |
3352 | to make sure you link against any libraries where the \f(CW\*(C`clock_gettime\*(C'\fR |
3292 | function is hiding in (often \fI\-lrt\fR). |
3353 | function is hiding in (often \fI\-lrt\fR). See also \f(CW\*(C`EV_USE_CLOCK_SYSCALL\*(C'\fR. |
3293 | .IP "\s-1EV_USE_REALTIME\s0" 4 |
3354 | .IP "\s-1EV_USE_REALTIME\s0" 4 |
3294 | .IX Item "EV_USE_REALTIME" |
3355 | .IX Item "EV_USE_REALTIME" |
3295 | If defined to be \f(CW1\fR, libev will try to detect the availability of the |
3356 | If defined to be \f(CW1\fR, libev will try to detect the availability of the |
3296 | real-time clock option at compile time (and assume its availability at |
3357 | real-time clock option at compile time (and assume its availability |
3297 | runtime if successful). Otherwise no use of the real-time clock option will |
3358 | at runtime if successful). Otherwise no use of the real-time clock |
3298 | be attempted. This effectively replaces \f(CW\*(C`gettimeofday\*(C'\fR by \f(CW\*(C`clock_get |
3359 | option will be attempted. This effectively replaces \f(CW\*(C`gettimeofday\*(C'\fR |
3299 | (CLOCK_REALTIME, ...)\*(C'\fR and will not normally affect correctness. See the |
3360 | by \f(CW\*(C`clock_get (CLOCK_REALTIME, ...)\*(C'\fR and will not normally affect |
3300 | note about libraries in the description of \f(CW\*(C`EV_USE_MONOTONIC\*(C'\fR, though. |
3361 | correctness. See the note about libraries in the description of |
|
|
3362 | \&\f(CW\*(C`EV_USE_MONOTONIC\*(C'\fR, though. Defaults to the opposite value of |
|
|
3363 | \&\f(CW\*(C`EV_USE_CLOCK_SYSCALL\*(C'\fR. |
|
|
3364 | .IP "\s-1EV_USE_CLOCK_SYSCALL\s0" 4 |
|
|
3365 | .IX Item "EV_USE_CLOCK_SYSCALL" |
|
|
3366 | If defined to be \f(CW1\fR, libev will try to use a direct syscall instead |
|
|
3367 | of calling the system-provided \f(CW\*(C`clock_gettime\*(C'\fR function. This option |
|
|
3368 | exists because on GNU/Linux, \f(CW\*(C`clock_gettime\*(C'\fR is in \f(CW\*(C`librt\*(C'\fR, but \f(CW\*(C`librt\*(C'\fR |
|
|
3369 | unconditionally pulls in \f(CW\*(C`libpthread\*(C'\fR, slowing down single-threaded |
|
|
3370 | programs needlessly. Using a direct syscall is slightly slower (in |
|
|
3371 | theory), because no optimised vdso implementation can be used, but avoids |
|
|
3372 | the pthread dependency. Defaults to \f(CW1\fR on GNU/Linux with glibc 2.x or |
|
|
3373 | higher, as it simplifies linking (no need for \f(CW\*(C`\-lrt\*(C'\fR). |
3301 | .IP "\s-1EV_USE_NANOSLEEP\s0" 4 |
3374 | .IP "\s-1EV_USE_NANOSLEEP\s0" 4 |
3302 | .IX Item "EV_USE_NANOSLEEP" |
3375 | .IX Item "EV_USE_NANOSLEEP" |
3303 | If defined to be \f(CW1\fR, libev will assume that \f(CW\*(C`nanosleep ()\*(C'\fR is available |
3376 | If defined to be \f(CW1\fR, libev will assume that \f(CW\*(C`nanosleep ()\*(C'\fR is available |
3304 | and will use it for delays. Otherwise it will use \f(CW\*(C`select ()\*(C'\fR. |
3377 | and will use it for delays. Otherwise it will use \f(CW\*(C`select ()\*(C'\fR. |
3305 | .IP "\s-1EV_USE_EVENTFD\s0" 4 |
3378 | .IP "\s-1EV_USE_EVENTFD\s0" 4 |
… | |
… | |
3317 | will not be compiled in. |
3390 | will not be compiled in. |
3318 | .IP "\s-1EV_SELECT_USE_FD_SET\s0" 4 |
3391 | .IP "\s-1EV_SELECT_USE_FD_SET\s0" 4 |
3319 | .IX Item "EV_SELECT_USE_FD_SET" |
3392 | .IX Item "EV_SELECT_USE_FD_SET" |
3320 | If defined to \f(CW1\fR, then the select backend will use the system \f(CW\*(C`fd_set\*(C'\fR |
3393 | If defined to \f(CW1\fR, then the select backend will use the system \f(CW\*(C`fd_set\*(C'\fR |
3321 | structure. This is useful if libev doesn't compile due to a missing |
3394 | structure. This is useful if libev doesn't compile due to a missing |
3322 | \&\f(CW\*(C`NFDBITS\*(C'\fR or \f(CW\*(C`fd_mask\*(C'\fR definition or it mis-guesses the bitset layout on |
3395 | \&\f(CW\*(C`NFDBITS\*(C'\fR or \f(CW\*(C`fd_mask\*(C'\fR definition or it mis-guesses the bitset layout |
3323 | exotic systems. This usually limits the range of file descriptors to some |
3396 | on exotic systems. This usually limits the range of file descriptors to |
3324 | low limit such as 1024 or might have other limitations (winsocket only |
3397 | some low limit such as 1024 or might have other limitations (winsocket |
3325 | allows 64 sockets). The \f(CW\*(C`FD_SETSIZE\*(C'\fR macro, set before compilation, might |
3398 | only allows 64 sockets). The \f(CW\*(C`FD_SETSIZE\*(C'\fR macro, set before compilation, |
3326 | influence the size of the \f(CW\*(C`fd_set\*(C'\fR used. |
3399 | configures the maximum size of the \f(CW\*(C`fd_set\*(C'\fR. |
3327 | .IP "\s-1EV_SELECT_IS_WINSOCKET\s0" 4 |
3400 | .IP "\s-1EV_SELECT_IS_WINSOCKET\s0" 4 |
3328 | .IX Item "EV_SELECT_IS_WINSOCKET" |
3401 | .IX Item "EV_SELECT_IS_WINSOCKET" |
3329 | When defined to \f(CW1\fR, the select backend will assume that |
3402 | When defined to \f(CW1\fR, the select backend will assume that |
3330 | select/socket/connect etc. don't understand file descriptors but |
3403 | select/socket/connect etc. don't understand file descriptors but |
3331 | wants osf handles on win32 (this is the case when the select to |
3404 | wants osf handles on win32 (this is the case when the select to |