… | |
… | |
35 | warn "sigquit received\n"; |
35 | warn "sigquit received\n"; |
36 | }; |
36 | }; |
37 | |
37 | |
38 | # CHILD/PID STATUS CHANGES |
38 | # CHILD/PID STATUS CHANGES |
39 | |
39 | |
40 | my $w = EV::child 666, sub { |
40 | my $w = EV::child 666, 0, sub { |
41 | my ($w, $revents) = @_; |
41 | my ($w, $revents) = @_; |
42 | my $status = $w->rstatus; |
42 | my $status = $w->rstatus; |
43 | }; |
43 | }; |
44 | |
44 | |
45 | # STAT CHANGES |
45 | # STAT CHANGES |
… | |
… | |
68 | package EV; |
68 | package EV; |
69 | |
69 | |
70 | use strict; |
70 | use strict; |
71 | |
71 | |
72 | BEGIN { |
72 | BEGIN { |
73 | our $VERSION = '2.0'; |
73 | our $VERSION = '3.3'; |
74 | use XSLoader; |
74 | use XSLoader; |
75 | XSLoader::load "EV", $VERSION; |
75 | XSLoader::load "EV", $VERSION; |
76 | } |
76 | } |
77 | |
77 | |
78 | @EV::IO::ISA = |
78 | @EV::IO::ISA = |
… | |
… | |
84 | @EV::Idle::ISA = |
84 | @EV::Idle::ISA = |
85 | @EV::Prepare::ISA = |
85 | @EV::Prepare::ISA = |
86 | @EV::Check::ISA = |
86 | @EV::Check::ISA = |
87 | @EV::Embed::ISA = |
87 | @EV::Embed::ISA = |
88 | @EV::Fork::ISA = |
88 | @EV::Fork::ISA = |
|
|
89 | @EV::Async::ISA = |
89 | "EV::Watcher"; |
90 | "EV::Watcher"; |
90 | |
91 | |
91 | @EV::Loop::Default::ISA = "EV::Loop"; |
92 | @EV::Loop::Default::ISA = "EV::Loop"; |
92 | |
93 | |
93 | =head1 EVENT LOOPS |
94 | =head1 EVENT LOOPS |
… | |
… | |
155 | |
156 | |
156 | Returns the set (see C<EV::BACKEND_*> flags) of backends supported by this |
157 | Returns the set (see C<EV::BACKEND_*> flags) of backends supported by this |
157 | instance of EV, the set of recommended backends (supposed to be good) for |
158 | instance of EV, the set of recommended backends (supposed to be good) for |
158 | this platform and the set of embeddable backends (see EMBED WATCHERS). |
159 | this platform and the set of embeddable backends (see EMBED WATCHERS). |
159 | |
160 | |
|
|
161 | =item EV::sleep $seconds |
|
|
162 | |
|
|
163 | Block the process for the given number of (fractional) seconds. |
|
|
164 | |
160 | =item $time = EV::time |
165 | =item $time = EV::time |
161 | |
166 | |
162 | Returns the current time in (fractional) seconds since the epoch. |
167 | Returns the current time in (fractional) seconds since the epoch. |
163 | |
168 | |
164 | =item $time = EV::now |
169 | =item $time = EV::now |
… | |
… | |
529 | This time simply fires at the wallclock time C<$at> and doesn't repeat. It |
534 | This time simply fires at the wallclock time C<$at> and doesn't repeat. It |
530 | will not adjust when a time jump occurs, that is, if it is to be run |
535 | will not adjust when a time jump occurs, that is, if it is to be run |
531 | at January 1st 2011 then it will run when the system time reaches or |
536 | at January 1st 2011 then it will run when the system time reaches or |
532 | surpasses this time. |
537 | surpasses this time. |
533 | |
538 | |
534 | =item * non-repeating interval timer ($interval > 0, $reschedule_cb = 0) |
539 | =item * repeating interval timer ($interval > 0, $reschedule_cb = 0) |
535 | |
540 | |
536 | In this mode the watcher will always be scheduled to time out at the |
541 | In this mode the watcher will always be scheduled to time out at the |
537 | next C<$at + N * $interval> time (for some integer N) and then repeat, |
542 | next C<$at + N * $interval> time (for some integer N) and then repeat, |
538 | regardless of any time jumps. |
543 | regardless of any time jumps. |
539 | |
544 | |
… | |
… | |
640 | |
645 | |
641 | =head3 CHILD WATCHERS - watch out for process status changes |
646 | =head3 CHILD WATCHERS - watch out for process status changes |
642 | |
647 | |
643 | =over 4 |
648 | =over 4 |
644 | |
649 | |
645 | =item $w = EV::child $pid, $callback |
650 | =item $w = EV::child $pid, $trace, $callback |
646 | |
651 | |
647 | =item $w = EV::child_ns $pid, $callback |
652 | =item $w = EV::child_ns $pid, $trace, $callback |
648 | |
653 | |
649 | =item $w = $loop->child ($pid, $callback) |
654 | =item $w = $loop->child ($pid, $trace, $callback) |
650 | |
655 | |
651 | =item $w = $loop->child_ns ($pid, $callback) |
656 | =item $w = $loop->child_ns ($pid, $trace, $callback) |
652 | |
657 | |
653 | Call the callback when a status change for pid C<$pid> (or any pid if |
658 | Call the callback when a status change for pid C<$pid> (or any pid |
654 | C<$pid> is 0) has been received. More precisely: when the process receives |
659 | if C<$pid> is 0) has been received (a status change happens when the |
|
|
660 | process terminates or is killed, or, when trace is true, additionally when |
|
|
661 | it is stopped or continued). More precisely: when the process receives |
655 | a C<SIGCHLD>, EV will fetch the outstanding exit/wait status for all |
662 | a C<SIGCHLD>, EV will fetch the outstanding exit/wait status for all |
656 | changed/zombie children and call the callback. |
663 | changed/zombie children and call the callback. |
657 | |
664 | |
658 | It is valid (and fully supported) to install a child watcher after a child |
665 | It is valid (and fully supported) to install a child watcher after a child |
659 | has exited but before the event loop has started its next iteration (for |
666 | has exited but before the event loop has started its next iteration (for |
… | |
… | |
666 | You can have as many pid watchers per pid as you want, they will all be |
673 | You can have as many pid watchers per pid as you want, they will all be |
667 | called. |
674 | called. |
668 | |
675 | |
669 | The C<child_ns> variant doesn't start (activate) the newly created watcher. |
676 | The C<child_ns> variant doesn't start (activate) the newly created watcher. |
670 | |
677 | |
671 | =item $w->set ($pid) |
678 | =item $w->set ($pid, $trace) |
672 | |
679 | |
673 | Reconfigures the watcher, see the constructor above for details. Can be called at |
680 | Reconfigures the watcher, see the constructor above for details. Can be called at |
674 | any time. |
681 | any time. |
675 | |
682 | |
676 | =item $current_pid = $w->pid |
683 | =item $current_pid = $w->pid |
677 | |
|
|
678 | =item $old_pid = $w->pid ($new_pid) |
|
|
679 | |
684 | |
680 | Returns the previously set process id and optionally set a new one. |
685 | Returns the previously set process id and optionally set a new one. |
681 | |
686 | |
682 | =item $exit_status = $w->rstatus |
687 | =item $exit_status = $w->rstatus |
683 | |
688 | |
… | |
… | |
964 | |
969 | |
965 | The C<embed_ns> variant doesn't start (activate) the newly created watcher. |
970 | The C<embed_ns> variant doesn't start (activate) the newly created watcher. |
966 | |
971 | |
967 | =back |
972 | =back |
968 | |
973 | |
|
|
974 | =head3 ASYNC WATCHERS - how to wake up another event loop |
|
|
975 | |
|
|
976 | Async watchers are provided by EV, but have little use in perl directly, as perl |
|
|
977 | neither supports threads nor direct access to signal handlers or other |
|
|
978 | contexts where they could be of value. |
|
|
979 | |
|
|
980 | It is, however, possible to use them from the XS level. |
|
|
981 | |
|
|
982 | Please see the libev documentation for further details. |
|
|
983 | |
|
|
984 | =over 4 |
|
|
985 | |
|
|
986 | =item $w = EV::async $callback |
|
|
987 | |
|
|
988 | =item $w = EV::async_ns $callback |
|
|
989 | |
|
|
990 | =item $w->send |
|
|
991 | |
|
|
992 | =item $bool = $w->async_pending |
|
|
993 | |
|
|
994 | =back |
|
|
995 | |
969 | |
996 | |
970 | =head1 PERL SIGNALS |
997 | =head1 PERL SIGNALS |
971 | |
998 | |
972 | While Perl signal handling (C<%SIG>) is not affected by EV, the behaviour |
999 | While Perl signal handling (C<%SIG>) is not affected by EV, the behaviour |
973 | with EV is as the same as any other C library: Perl-signals will only be |
1000 | with EV is as the same as any other C library: Perl-signals will only be |