ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent.pm (file contents):
Revision 1.20 by root, Mon Dec 11 01:16:09 2006 UTC vs.
Revision 1.25 by root, Wed Apr 11 00:36:59 2007 UTC

161 161
162=head2 SIGNAL WATCHERS 162=head2 SIGNAL WATCHERS
163 163
164You can listen for signals using a signal watcher, C<signal> is the signal 164You can listen for signals using a signal watcher, C<signal> is the signal
165I<name> without any C<SIG> prefix. Multiple signals events can be clumped 165I<name> without any C<SIG> prefix. Multiple signals events can be clumped
166together into one callback invocation, and callbakc invocation might or 166together into one callback invocation, and callback invocation might or
167might not be asynchronous. 167might not be asynchronous.
168 168
169These watchers might use C<%SIG>, so programs overwriting those signals 169These watchers might use C<%SIG>, so programs overwriting those signals
170directly will likely not work correctly. 170directly will likely not work correctly.
171 171
245 245
246package AnyEvent; 246package AnyEvent;
247 247
248no warnings; 248no warnings;
249use strict; 249use strict;
250
250use Carp; 251use Carp;
251 252
252our $VERSION = '2.5'; 253our $VERSION = '2.52';
253our $MODEL; 254our $MODEL;
254 255
255our $AUTOLOAD; 256our $AUTOLOAD;
256our @ISA; 257our @ISA;
257 258
288 unless ($MODEL) { 289 unless ($MODEL) {
289 # try to load a model 290 # try to load a model
290 291
291 for (@REGISTRY, @models) { 292 for (@REGISTRY, @models) {
292 my ($package, $model) = @$_; 293 my ($package, $model) = @$_;
294 if (eval "require $package"
295 and ${"$package\::VERSION"} > 0
293 if (eval "require $model") { 296 and eval "require $model") {
294 $MODEL = $model; 297 $MODEL = $model;
295 warn "AnyEvent: autoprobed and loaded model '$model', using it.\n" if $verbose > 1; 298 warn "AnyEvent: autoprobed and loaded model '$model', using it.\n" if $verbose > 1;
296 last; 299 last;
297 } 300 }
298 } 301 }
384 or Carp::croak "required option 'pid' is missing"; 387 or Carp::croak "required option 'pid' is missing";
385 388
386 $PID_CB{$pid}{$arg{cb}} = $arg{cb}; 389 $PID_CB{$pid}{$arg{cb}} = $arg{cb};
387 390
388 unless ($WNOHANG) { 391 unless ($WNOHANG) {
389 $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_child_wait);
390 $WNOHANG = eval { require POSIX; &POSIX::WNOHANG } || 1; 392 $WNOHANG = eval { require POSIX; &POSIX::WNOHANG } || 1;
391 } 393 }
392 394
395 unless ($CHLD_W) {
396 $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_child_wait);
393 # child could be a zombie already 397 # child could be a zombie already
394 $PID_IDLE ||= AnyEvent->timer (after => 0, cb => \&_child_wait); 398 $PID_IDLE ||= AnyEvent->timer (after => 0, cb => \&_child_wait);
399 }
395 400
396 bless [$pid, $arg{cb}], "AnyEvent::Base::Child" 401 bless [$pid, $arg{cb}], "AnyEvent::Base::Child"
397} 402}
398 403
399sub AnyEvent::Base::Child::DESTROY { 404sub AnyEvent::Base::Child::DESTROY {
435I<rxvt-unicode> distribution. 440I<rxvt-unicode> distribution.
436 441
437I<rxvt-unicode> also cheats a bit by not providing blocking access to 442I<rxvt-unicode> also cheats a bit by not providing blocking access to
438condition variables: code blocking while waiting for a condition will 443condition variables: code blocking while waiting for a condition will
439C<die>. This still works with most modules/usages, and blocking calls must 444C<die>. This still works with most modules/usages, and blocking calls must
440not be in an interactive appliation, so it makes sense. 445not be in an interactive application, so it makes sense.
441 446
442=head1 ENVIRONMENT VARIABLES 447=head1 ENVIRONMENT VARIABLES
443 448
444The following environment variables are used by this module: 449The following environment variables are used by this module:
445 450

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines