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

Comparing libev/ev.pod (file contents):
Revision 1.422 by root, Thu Nov 15 01:39:45 2012 UTC vs.
Revision 1.423 by root, Fri Nov 23 12:52:35 2012 UTC

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