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

Comparing libev/ev.pod (file contents):
Revision 1.421 by root, Thu Aug 2 11:55:28 2012 UTC vs.
Revision 1.424 by root, Sun Nov 25 01:38:51 2012 UTC

569kernel is more efficient (which says nothing about its actual speed, of 569kernel is more efficient (which says nothing about its actual speed, of
570course). While stopping, setting and starting an I/O watcher does never 570course). While stopping, setting and starting an I/O watcher does never
571cause an extra system call as with C<EVBACKEND_EPOLL>, it still adds up to 571cause an extra system call as with C<EVBACKEND_EPOLL>, it still adds up to
572two event changes per incident. Support for C<fork ()> is very bad (you 572two event changes per incident. Support for C<fork ()> is very bad (you
573might have to leak fd's on fork, but it's more sane than epoll) and it 573might have to leak fd's on fork, but it's more sane than epoll) and it
574drops fds silently in similarly hard-to-detect cases 574drops fds silently in similarly hard-to-detect cases.
575 575
576This backend usually performs well under most conditions. 576This backend usually performs well under most conditions.
577 577
578While nominally embeddable in other event loops, this doesn't work 578While nominally embeddable in other event loops, this doesn't work
579everywhere, so you might need to test for this. And since it is broken 579everywhere, so you might need to test for this. And since it is broken
1393transition between them will be described in more detail - and while these 1393transition between them will be described in more detail - and while these
1394rules might look complicated, they usually do "the right thing". 1394rules might look complicated, they usually do "the right thing".
1395 1395
1396=over 4 1396=over 4
1397 1397
1398=item initialiased 1398=item initialised
1399 1399
1400Before a watcher can be registered with the event loop it has to be 1400Before a watcher can be registered with the event loop it has to be
1401initialised. This can be done with a call to C<ev_TYPE_init>, or calls to 1401initialised. This can be done with a call to C<ev_TYPE_init>, or calls to
1402C<ev_init> followed by the watcher-specific C<ev_TYPE_set> function. 1402C<ev_init> followed by the watcher-specific C<ev_TYPE_set> function.
1403 1403
3177 3177
3178=over 4 3178=over 4
3179 3179
3180=item ev_embed_init (ev_embed *, callback, struct ev_loop *embedded_loop) 3180=item ev_embed_init (ev_embed *, callback, struct ev_loop *embedded_loop)
3181 3181
3182=item ev_embed_set (ev_embed *, callback, struct ev_loop *embedded_loop) 3182=item ev_embed_set (ev_embed *, struct ev_loop *embedded_loop)
3183 3183
3184Configures the watcher to embed the given loop, which must be 3184Configures the watcher to embed the given loop, which must be
3185embeddable. If the callback is C<0>, then C<ev_embed_sweep> will be 3185embeddable. If the callback is C<0>, then C<ev_embed_sweep> will be
3186invoked automatically, otherwise it is the responsibility of the callback 3186invoked automatically, otherwise it is the responsibility of the callback
3187to invoke it (it will continue to be called until the sweep has been done, 3187to invoke it (it will continue to be called until the sweep has been done,
3658already been invoked. 3658already been invoked.
3659 3659
3660A common way around all these issues is to make sure that 3660A common way around all these issues is to make sure that
3661C<start_new_request> I<always> returns before the callback is invoked. If 3661C<start_new_request> I<always> returns before the callback is invoked. If
3662C<start_new_request> immediately knows the result, it can artificially 3662C<start_new_request> immediately knows the result, it can artificially
3663delay invoking the callback by e.g. using a C<prepare> or C<idle> watcher 3663delay invoking the callback by using a C<prepare> or C<idle> watcher for
3664for example, or more sneakily, by reusing an existing (stopped) watcher 3664example, or more sneakily, by reusing an existing (stopped) watcher and
3665and pushing it into the pending queue: 3665pushing it into the pending queue:
3666 3666
3667 ev_set_cb (watcher, callback); 3667 ev_set_cb (watcher, callback);
3668 ev_feed_event (EV_A_ watcher, 0); 3668 ev_feed_event (EV_A_ watcher, 0);
3669 3669
3670This way, C<start_new_request> can safely return before the callback is 3670This way, C<start_new_request> can safely return before the callback is
3678 3678
3679This brings the problem of exiting - a callback might want to finish the 3679This brings the problem of exiting - a callback might want to finish the
3680main C<ev_run> call, but not the nested one (e.g. user clicked "Quit", but 3680main C<ev_run> call, but not the nested one (e.g. user clicked "Quit", but
3681a modal "Are you sure?" dialog is still waiting), or just the nested one 3681a modal "Are you sure?" dialog is still waiting), or just the nested one
3682and not the main one (e.g. user clocked "Ok" in a modal dialog), or some 3682and not the main one (e.g. user clocked "Ok" in a modal dialog), or some
3683other combination: In these cases, C<ev_break> will not work alone. 3683other combination: In these cases, a simple C<ev_break> will not work.
3684 3684
3685The solution is to maintain "break this loop" variable for each C<ev_run> 3685The solution is to maintain "break this loop" variable for each C<ev_run>
3686invocation, and use a loop around C<ev_run> until the condition is 3686invocation, and use a loop around C<ev_run> until the condition is
3687triggered, using C<EVRUN_ONCE>: 3687triggered, using C<EVRUN_ONCE>:
3688 3688

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines