ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.pod
(Generate patch)

Comparing libev/ev.pod (file contents):
Revision 1.245 by root, Tue Jun 30 06:24:38 2009 UTC vs.
Revision 1.251 by root, Fri Jul 10 00:36:21 2009 UTC

620happily wraps around with enough iterations. 620happily wraps around with enough iterations.
621 621
622This value can sometimes be useful as a generation counter of sorts (it 622This value can sometimes be useful as a generation counter of sorts (it
623"ticks" the number of loop iterations), as it roughly corresponds with 623"ticks" the number of loop iterations), as it roughly corresponds with
624C<ev_prepare> and C<ev_check> calls. 624C<ev_prepare> and C<ev_check> calls.
625
626=item unsigned int ev_loop_depth (loop)
627
628Returns the number of times C<ev_loop> was entered minus the number of
629times C<ev_loop> was exited, in other words, the recursion depth.
630
631Outside C<ev_loop>, this number is zero. In a callback, this number is
632C<1>, unless C<ev_loop> was invoked recursively (or from another thread),
633in which case it is higher.
634
635Leaving C<ev_loop> abnormally (setjmp/longjmp, cancelling the thread
636etc.), doesn't count as exit.
625 637
626=item unsigned int ev_backend (loop) 638=item unsigned int ev_backend (loop)
627 639
628Returns one of the C<EVBACKEND_*> flags indicating the event backend in 640Returns one of the C<EVBACKEND_*> flags indicating the event backend in
629use. 641use.
1480 1492
1481The callback is guaranteed to be invoked only I<after> its timeout has 1493The callback is guaranteed to be invoked only I<after> its timeout has
1482passed (not I<at>, so on systems with very low-resolution clocks this 1494passed (not I<at>, so on systems with very low-resolution clocks this
1483might introduce a small delay). If multiple timers become ready during the 1495might introduce a small delay). If multiple timers become ready during the
1484same loop iteration then the ones with earlier time-out values are invoked 1496same loop iteration then the ones with earlier time-out values are invoked
1485before ones with later time-out values (but this is no longer true when a 1497before ones of the same priority with later time-out values (but this is
1486callback calls C<ev_loop> recursively). 1498no longer true when a callback calls C<ev_loop> recursively).
1487 1499
1488=head3 Be smart about timeouts 1500=head3 Be smart about timeouts
1489 1501
1490Many real-world problems involve some kind of timeout, usually for error 1502Many real-world problems involve some kind of timeout, usually for error
1491recovery. A typical example is an HTTP request - if the other side hangs, 1503recovery. A typical example is an HTTP request - if the other side hangs,
2019but forking and registering a watcher a few event loop iterations later or 2031but forking and registering a watcher a few event loop iterations later or
2020in the next callback invocation is not. 2032in the next callback invocation is not.
2021 2033
2022Only the default event loop is capable of handling signals, and therefore 2034Only the default event loop is capable of handling signals, and therefore
2023you can only register child watchers in the default event loop. 2035you can only register child watchers in the default event loop.
2036
2037Due to some design glitches inside libev, child watchers will always be
2038handled at maximum priority (their priority is set to C<EV_MAXPRI> by
2039libev)
2024 2040
2025=head3 Process Interaction 2041=head3 Process Interaction
2026 2042
2027Libev grabs C<SIGCHLD> as soon as the default event loop is 2043Libev grabs C<SIGCHLD> as soon as the default event loop is
2028initialised. This is necessary to guarantee proper behaviour even if 2044initialised. This is necessary to guarantee proper behaviour even if
3655defined to be C<0>, then they are not. 3671defined to be C<0>, then they are not.
3656 3672
3657=item EV_MINIMAL 3673=item EV_MINIMAL
3658 3674
3659If you need to shave off some kilobytes of code at the expense of some 3675If you need to shave off some kilobytes of code at the expense of some
3660speed, define this symbol to C<1>. Currently this is used to override some 3676speed (but with the full API), define this symbol to C<1>. Currently this
3661inlining decisions, saves roughly 30% code size on amd64. It also selects a 3677is used to override some inlining decisions, saves roughly 30% code size
3662much smaller 2-heap for timer management over the default 4-heap. 3678on amd64. It also selects a much smaller 2-heap for timer management over
3679the default 4-heap.
3680
3681You can save even more by disabling watcher types you do not need and
3682setting C<EV_MAXPRI> == C<EV_MINPRI>.
3683
3684Defining C<EV_MINIMAL> to C<2> will additionally reduce the core API to
3685provide a bare-bones event library. See C<ev.h> for details on what parts
3686of the API are still available, and do not complain if this subset changes
3687over time.
3663 3688
3664=item EV_PID_HASHSIZE 3689=item EV_PID_HASHSIZE
3665 3690
3666C<ev_child> watchers use a small hash table to distribute workload by 3691C<ev_child> watchers use a small hash table to distribute workload by
3667pid. The default size is C<16> (or C<1> with C<EV_MINIMAL>), usually more 3692pid. The default size is C<16> (or C<1> with C<EV_MINIMAL>), usually more
4077=item C<double> must hold a time value in seconds with enough accuracy 4102=item C<double> must hold a time value in seconds with enough accuracy
4078 4103
4079The type C<double> is used to represent timestamps. It is required to 4104The type C<double> is used to represent timestamps. It is required to
4080have at least 51 bits of mantissa (and 9 bits of exponent), which is good 4105have at least 51 bits of mantissa (and 9 bits of exponent), which is good
4081enough for at least into the year 4000. This requirement is fulfilled by 4106enough for at least into the year 4000. This requirement is fulfilled by
4082implementations implementing IEEE 754 (basically all existing ones). 4107implementations implementing IEEE 754, which is basically all existing
4108ones. With IEEE 754 doubles, you get microsecond accuracy until at least
41092200.
4083 4110
4084=back 4111=back
4085 4112
4086If you know of other additional requirements drop me a note. 4113If you know of other additional requirements drop me a note.
4087 4114

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines