… | |
… | |
195 | C<AnyEvent::Impl:xxx> modules, but can be any other class in the case |
195 | C<AnyEvent::Impl:xxx> modules, but can be any other class in the case |
196 | AnyEvent has been extended at runtime (e.g. in I<rxvt-unicode>). |
196 | AnyEvent has been extended at runtime (e.g. in I<rxvt-unicode>). |
197 | |
197 | |
198 | The known classes so far are: |
198 | The known classes so far are: |
199 | |
199 | |
|
|
200 | EV::AnyEvent based on EV (an interface to libev, best choice) |
200 | AnyEvent::Impl::Coro based on Coro::Event, best choice. |
201 | AnyEvent::Impl::Coro based on Coro::Event, second best choice. |
201 | EV::AnyEvent based on EV (an interface to libevent) |
|
|
202 | AnyEvent::Impl::Event based on Event, also best choice :) |
202 | AnyEvent::Impl::Event based on Event, also second best choice :) |
203 | AnyEvent::Impl::Glib based on Glib, second-best choice. |
203 | AnyEvent::Impl::Glib based on Glib, second-best choice. |
204 | AnyEvent::Impl::Tk based on Tk, very bad choice. |
204 | AnyEvent::Impl::Tk based on Tk, very bad choice. |
205 | AnyEvent::Impl::Perl pure-perl implementation, inefficient. |
205 | AnyEvent::Impl::Perl pure-perl implementation, inefficient. |
206 | |
206 | |
207 | =item AnyEvent::detect |
207 | =item AnyEvent::detect |
… | |
… | |
349 | my (undef, %arg) = @_; |
349 | my (undef, %arg) = @_; |
350 | |
350 | |
351 | my $signal = uc $arg{signal} |
351 | my $signal = uc $arg{signal} |
352 | or Carp::croak "required option 'signal' is missing"; |
352 | or Carp::croak "required option 'signal' is missing"; |
353 | |
353 | |
354 | $SIG_CB{$signal}{$arg{cb}} = $arg{cb}; |
354 | $SIG_CB{$signal}{$arg{cb} += 0} = $arg{cb}; |
355 | $SIG{$signal} ||= sub { |
355 | $SIG{$signal} ||= sub { |
356 | $_->() for values %{ $SIG_CB{$signal} || {} }; |
356 | $_->() for values %{ $SIG_CB{$signal} || {} }; |
357 | }; |
357 | }; |
358 | |
358 | |
359 | bless [$signal, $arg{cb}], "AnyEvent::Base::Signal" |
359 | bless [$signal, $arg{cb}], "AnyEvent::Base::Signal" |
… | |
… | |
374 | our $PID_IDLE; |
374 | our $PID_IDLE; |
375 | our $WNOHANG; |
375 | our $WNOHANG; |
376 | |
376 | |
377 | sub _child_wait { |
377 | sub _child_wait { |
378 | while (0 < (my $pid = waitpid -1, $WNOHANG)) { |
378 | while (0 < (my $pid = waitpid -1, $WNOHANG)) { |
379 | $_->() for values %{ (delete $PID_CB{$pid}) || {} }; |
379 | $_->() for values %{ $PID_CB{$pid} || {} }, %{ $PID_CB{0} || {} }; |
380 | } |
380 | } |
381 | |
381 | |
382 | undef $PID_IDLE; |
382 | undef $PID_IDLE; |
383 | } |
383 | } |
384 | |
384 | |