… | |
… | |
575 | be handled here by queueing them when their watcher gets executed. |
575 | be handled here by queueing them when their watcher gets executed. |
576 | - If ev_unloop has been called, or EVLOOP_ONESHOT or EVLOOP_NONBLOCK |
576 | - If ev_unloop has been called, or EVLOOP_ONESHOT or EVLOOP_NONBLOCK |
577 | were used, or there are no active watchers, return, otherwise |
577 | were used, or there are no active watchers, return, otherwise |
578 | continue with step *. |
578 | continue with step *. |
579 | |
579 | |
580 | Example: Queue some jobs and then loop until no events are outsanding |
580 | Example: Queue some jobs and then loop until no events are outstanding |
581 | anymore. |
581 | anymore. |
582 | |
582 | |
583 | ... queue jobs here, make sure they register event watchers as long |
583 | ... queue jobs here, make sure they register event watchers as long |
584 | ... as they still have work to do (even an idle watcher will do..) |
584 | ... as they still have work to do (even an idle watcher will do..) |
585 | ev_loop (my_loop, 0); |
585 | ev_loop (my_loop, 0); |
… | |
… | |
589 | |
589 | |
590 | Can be used to make a call to C<ev_loop> return early (but only after it |
590 | Can be used to make a call to C<ev_loop> return early (but only after it |
591 | has processed all outstanding events). The C<how> argument must be either |
591 | has processed all outstanding events). The C<how> argument must be either |
592 | C<EVUNLOOP_ONE>, which will make the innermost C<ev_loop> call return, or |
592 | C<EVUNLOOP_ONE>, which will make the innermost C<ev_loop> call return, or |
593 | C<EVUNLOOP_ALL>, which will make all nested C<ev_loop> calls return. |
593 | C<EVUNLOOP_ALL>, which will make all nested C<ev_loop> calls return. |
|
|
594 | |
|
|
595 | This "unloop state" will be cleared when entering C<ev_loop> again. |
594 | |
596 | |
595 | =item ev_ref (loop) |
597 | =item ev_ref (loop) |
596 | |
598 | |
597 | =item ev_unref (loop) |
599 | =item ev_unref (loop) |
598 | |
600 | |
… | |
… | |
603 | returning, ev_unref() after starting, and ev_ref() before stopping it. For |
605 | returning, ev_unref() after starting, and ev_ref() before stopping it. For |
604 | example, libev itself uses this for its internal signal pipe: It is not |
606 | example, libev itself uses this for its internal signal pipe: It is not |
605 | visible to the libev user and should not keep C<ev_loop> from exiting if |
607 | visible to the libev user and should not keep C<ev_loop> from exiting if |
606 | no event watchers registered by it are active. It is also an excellent |
608 | no event watchers registered by it are active. It is also an excellent |
607 | way to do this for generic recurring timers or from within third-party |
609 | way to do this for generic recurring timers or from within third-party |
608 | libraries. Just remember to I<unref after start> and I<ref before stop>. |
610 | libraries. Just remember to I<unref after start> and I<ref before stop> |
|
|
611 | (but only if the watcher wasn't active before, or was active before, |
|
|
612 | respectively). |
609 | |
613 | |
610 | Example: Create a signal watcher, but keep it from keeping C<ev_loop> |
614 | Example: Create a signal watcher, but keep it from keeping C<ev_loop> |
611 | running when nothing else is active. |
615 | running when nothing else is active. |
612 | |
616 | |
613 | struct ev_signal exitsig; |
617 | struct ev_signal exitsig; |