… | |
… | |
124 | this argument. |
124 | this argument. |
125 | |
125 | |
126 | =head2 TIME REPRESENTATION |
126 | =head2 TIME REPRESENTATION |
127 | |
127 | |
128 | Libev represents time as a single floating point number, representing |
128 | Libev represents time as a single floating point number, representing |
129 | the (fractional) number of seconds since the (POSIX) epoch (somewhere |
129 | the (fractional) number of seconds since the (POSIX) epoch (in practise |
130 | near the beginning of 1970, details are complicated, don't ask). This |
130 | somewhere near the beginning of 1970, details are complicated, don't |
131 | type is called C<ev_tstamp>, which is what you should use too. It usually |
131 | ask). This type is called C<ev_tstamp>, which is what you should use |
132 | aliases to the C<double> type in C. When you need to do any calculations |
132 | too. It usually aliases to the C<double> type in C. When you need to do |
133 | on it, you should treat it as some floating point value. Unlike the name |
133 | any calculations on it, you should treat it as some floating point value. |
|
|
134 | |
134 | component C<stamp> might indicate, it is also used for time differences |
135 | Unlike the name component C<stamp> might indicate, it is also used for |
135 | throughout libev. |
136 | time differences (e.g. delays) throughout libev. |
136 | |
137 | |
137 | =head1 ERROR HANDLING |
138 | =head1 ERROR HANDLING |
138 | |
139 | |
139 | Libev knows three classes of errors: operating system errors, usage errors |
140 | Libev knows three classes of errors: operating system errors, usage errors |
140 | and internal errors (bugs). |
141 | and internal errors (bugs). |
… | |
… | |
191 | as this indicates an incompatible change. Minor versions are usually |
192 | as this indicates an incompatible change. Minor versions are usually |
192 | compatible to older versions, so a larger minor version alone is usually |
193 | compatible to older versions, so a larger minor version alone is usually |
193 | not a problem. |
194 | not a problem. |
194 | |
195 | |
195 | Example: Make sure we haven't accidentally been linked against the wrong |
196 | Example: Make sure we haven't accidentally been linked against the wrong |
196 | version. |
197 | version (note, however, that this will not detect ABI mismatches :). |
197 | |
198 | |
198 | assert (("libev version mismatch", |
199 | assert (("libev version mismatch", |
199 | ev_version_major () == EV_VERSION_MAJOR |
200 | ev_version_major () == EV_VERSION_MAJOR |
200 | && ev_version_minor () >= EV_VERSION_MINOR)); |
201 | && ev_version_minor () >= EV_VERSION_MINOR)); |
201 | |
202 | |
… | |
… | |
1403 | { |
1404 | { |
1404 | // stop the I/O watcher, we received the event, but |
1405 | // stop the I/O watcher, we received the event, but |
1405 | // are not yet ready to handle it. |
1406 | // are not yet ready to handle it. |
1406 | ev_io_stop (EV_A_ w); |
1407 | ev_io_stop (EV_A_ w); |
1407 | |
1408 | |
1408 | // start the idle watcher to ahndle the actual event. |
1409 | // start the idle watcher to handle the actual event. |
1409 | // it will not be executed as long as other watchers |
1410 | // it will not be executed as long as other watchers |
1410 | // with the default priority are receiving events. |
1411 | // with the default priority are receiving events. |
1411 | ev_idle_start (EV_A_ &idle); |
1412 | ev_idle_start (EV_A_ &idle); |
1412 | } |
1413 | } |
1413 | |
1414 | |
… | |
… | |
1545 | somewhere, as that would have given you a big clue). |
1546 | somewhere, as that would have given you a big clue). |
1546 | |
1547 | |
1547 | =head3 The special problem of accept()ing when you can't |
1548 | =head3 The special problem of accept()ing when you can't |
1548 | |
1549 | |
1549 | Many implementations of the POSIX C<accept> function (for example, |
1550 | Many implementations of the POSIX C<accept> function (for example, |
1550 | found in port-2004 Linux) have the peculiar behaviour of not removing a |
1551 | found in post-2004 Linux) have the peculiar behaviour of not removing a |
1551 | connection from the pending queue in all error cases. |
1552 | connection from the pending queue in all error cases. |
1552 | |
1553 | |
1553 | For example, larger servers often run out of file descriptors (because |
1554 | For example, larger servers often run out of file descriptors (because |
1554 | of resource limits), causing C<accept> to fail with C<ENFILE> but not |
1555 | of resource limits), causing C<accept> to fail with C<ENFILE> but not |
1555 | rejecting the connection, leading to libev signalling readiness on |
1556 | rejecting the connection, leading to libev signalling readiness on |
… | |
… | |
1773 | callback (loop, timer, EV_TIMER); |
1774 | callback (loop, timer, EV_TIMER); |
1774 | |
1775 | |
1775 | And when there is some activity, simply store the current time in |
1776 | And when there is some activity, simply store the current time in |
1776 | C<last_activity>, no libev calls at all: |
1777 | C<last_activity>, no libev calls at all: |
1777 | |
1778 | |
1778 | last_actiivty = ev_now (loop); |
1779 | last_activity = ev_now (loop); |
1779 | |
1780 | |
1780 | This technique is slightly more complex, but in most cases where the |
1781 | This technique is slightly more complex, but in most cases where the |
1781 | time-out is unlikely to be triggered, much more efficient. |
1782 | time-out is unlikely to be triggered, much more efficient. |
1782 | |
1783 | |
1783 | Changing the timeout is trivial as well (if it isn't hard-coded in the |
1784 | Changing the timeout is trivial as well (if it isn't hard-coded in the |
… | |
… | |
3341 | ev::io iow; |
3342 | ev::io iow; |
3342 | iow.set <myclass, &myclass::io_cb> (&obj); |
3343 | iow.set <myclass, &myclass::io_cb> (&obj); |
3343 | |
3344 | |
3344 | =item w->set (object *) |
3345 | =item w->set (object *) |
3345 | |
3346 | |
3346 | This is an B<experimental> feature that might go away in a future version. |
|
|
3347 | |
|
|
3348 | This is a variation of a method callback - leaving out the method to call |
3347 | This is a variation of a method callback - leaving out the method to call |
3349 | will default the method to C<operator ()>, which makes it possible to use |
3348 | will default the method to C<operator ()>, which makes it possible to use |
3350 | functor objects without having to manually specify the C<operator ()> all |
3349 | functor objects without having to manually specify the C<operator ()> all |
3351 | the time. Incidentally, you can then also leave out the template argument |
3350 | the time. Incidentally, you can then also leave out the template argument |
3352 | list. |
3351 | list. |
… | |
… | |
3664 | define before including (or compiling) any of its files. The default in |
3663 | define before including (or compiling) any of its files. The default in |
3665 | the absence of autoconf is documented for every option. |
3664 | the absence of autoconf is documented for every option. |
3666 | |
3665 | |
3667 | Symbols marked with "(h)" do not change the ABI, and can have different |
3666 | Symbols marked with "(h)" do not change the ABI, and can have different |
3668 | values when compiling libev vs. including F<ev.h>, so it is permissible |
3667 | values when compiling libev vs. including F<ev.h>, so it is permissible |
3669 | to redefine them before including F<ev.h> without breakign compatibility |
3668 | to redefine them before including F<ev.h> without breaking compatibility |
3670 | to a compiled library. All other symbols change the ABI, which means all |
3669 | to a compiled library. All other symbols change the ABI, which means all |
3671 | users of libev and the libev code itself must be compiled with compatible |
3670 | users of libev and the libev code itself must be compiled with compatible |
3672 | settings. |
3671 | settings. |
3673 | |
3672 | |
3674 | =over 4 |
3673 | =over 4 |
… | |
… | |
4644 | =item C<ev_loop_verify> renamed to C<ev_verify> |
4643 | =item C<ev_loop_verify> renamed to C<ev_verify> |
4645 | |
4644 | |
4646 | Most functions working on C<struct ev_loop> objects don't have an |
4645 | Most functions working on C<struct ev_loop> objects don't have an |
4647 | C<ev_loop_> prefix, so it was removed. Note that C<ev_loop_fork> is |
4646 | C<ev_loop_> prefix, so it was removed. Note that C<ev_loop_fork> is |
4648 | still called C<ev_loop_fork> because it would otherwise clash with the |
4647 | still called C<ev_loop_fork> because it would otherwise clash with the |
4649 | C<ev_frok> typedef. |
4648 | C<ev_fork> typedef. |
4650 | |
4649 | |
4651 | =item C<EV_TIMEOUT> renamed to C<EV_TIMER> in C<revents> |
4650 | =item C<EV_TIMEOUT> renamed to C<EV_TIMER> in C<revents> |
4652 | |
4651 | |
4653 | This is a simple rename - all other watcher types use their name |
4652 | This is a simple rename - all other watcher types use their name |
4654 | as revents flag, and now C<ev_timer> does, too. |
4653 | as revents flag, and now C<ev_timer> does, too. |