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

Comparing libev/ev.3 (file contents):
Revision 1.44 by root, Sat Dec 8 15:30:26 2007 UTC vs.
Revision 1.45 by root, Sat Dec 8 22:11:14 2007 UTC

634libev watchers. However, a pair of \f(CW\*(C`ev_prepare\*(C'\fR/\f(CW\*(C`ev_check\*(C'\fR watchers is 634libev watchers. However, a pair of \f(CW\*(C`ev_prepare\*(C'\fR/\f(CW\*(C`ev_check\*(C'\fR watchers is
635usually a better approach for this kind of thing. 635usually a better approach for this kind of thing.
636.Sp 636.Sp
637Here are the gory details of what \f(CW\*(C`ev_loop\*(C'\fR does: 637Here are the gory details of what \f(CW\*(C`ev_loop\*(C'\fR does:
638.Sp 638.Sp
639.Vb 18 639.Vb 19
640\& - Before the first iteration, call any pending watchers.
640\& * If there are no active watchers (reference count is zero), return. 641\& * If there are no active watchers (reference count is zero), return.
641\& - Queue prepare watchers and then call all outstanding watchers. 642\& - Queue all prepare watchers and then call all outstanding watchers.
642\& - If we have been forked, recreate the kernel state. 643\& - If we have been forked, recreate the kernel state.
643\& - Update the kernel state with all outstanding changes. 644\& - Update the kernel state with all outstanding changes.
644\& - Update the "event loop time". 645\& - Update the "event loop time".
645\& - Calculate for how long to block. 646\& - Calculate for how long to block.
646\& - Block the process, waiting for any events. 647\& - Block the process, waiting for any events.
1634are ready to run (it's actually more complicated: it only runs coroutines 1635are ready to run (it's actually more complicated: it only runs coroutines
1635with priority higher than or equal to the event loop and one coroutine 1636with priority higher than or equal to the event loop and one coroutine
1636of lower priority, but only once, using idle watchers to keep the event 1637of lower priority, but only once, using idle watchers to keep the event
1637loop from blocking if lower-priority coroutines are active, thus mapping 1638loop from blocking if lower-priority coroutines are active, thus mapping
1638low-priority coroutines to idle/background tasks). 1639low-priority coroutines to idle/background tasks).
1640.PP
1641It is recommended to give \f(CW\*(C`ev_check\*(C'\fR watchers highest (\f(CW\*(C`EV_MAXPRI\*(C'\fR)
1642priority, to ensure that they are being run before any other watchers
1643after the poll. Also, \f(CW\*(C`ev_check\*(C'\fR watchers (and \f(CW\*(C`ev_prepare\*(C'\fR watchers,
1644too) should not activate (\*(L"feed\*(R") events into libev. While libev fully
1645supports this, they will be called before other \f(CW\*(C`ev_check\*(C'\fR watchers did
1646their job. As \f(CW\*(C`ev_check\*(C'\fR watchers are often used to embed other event
1647loops those other event loops might be in an unusable state until their
1648\&\f(CW\*(C`ev_check\*(C'\fR watcher ran (always remind yourself to coexist peacefully with
1649others).
1639.IP "ev_prepare_init (ev_prepare *, callback)" 4 1650.IP "ev_prepare_init (ev_prepare *, callback)" 4
1640.IX Item "ev_prepare_init (ev_prepare *, callback)" 1651.IX Item "ev_prepare_init (ev_prepare *, callback)"
1641.PD 0 1652.PD 0
1642.IP "ev_check_init (ev_check *, callback)" 4 1653.IP "ev_check_init (ev_check *, callback)" 4
1643.IX Item "ev_check_init (ev_check *, callback)" 1654.IX Item "ev_check_init (ev_check *, callback)"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines