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.21 by root, Mon Dec 11 20:36:50 2006 UTC vs.
Revision 1.28 by root, Sat Oct 27 15:10:09 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
195C<AnyEvent::Impl:xxx> modules, but can be any other class in the case 195C<AnyEvent::Impl:xxx> modules, but can be any other class in the case
196AnyEvent has been extended at runtime (e.g. in I<rxvt-unicode>). 196AnyEvent has been extended at runtime (e.g. in I<rxvt-unicode>).
197 197
198The known classes so far are: 198The known classes so far are:
199 199
200 AnyEvent::Impl::Coro based on Coro::Event, best choise. 200 AnyEvent::Impl::Coro based on Coro::Event, best choice.
201 EV::AnyEvent based on EV (an interface to libevent)
201 AnyEvent::Impl::Event based on Event, also best choice :) 202 AnyEvent::Impl::Event based on Event, also best choice :)
202 AnyEvent::Impl::Glib based on Glib, second-best choice. 203 AnyEvent::Impl::Glib based on Glib, second-best choice.
203 AnyEvent::Impl::Tk based on Tk, very bad choice. 204 AnyEvent::Impl::Tk based on Tk, very bad choice.
204 AnyEvent::Impl::Perl pure-perl implementation, inefficient. 205 AnyEvent::Impl::Perl pure-perl implementation, inefficient.
205 206
245 246
246package AnyEvent; 247package AnyEvent;
247 248
248no warnings; 249no warnings;
249use strict; 250use strict;
251
250use Carp; 252use Carp;
251 253
252our $VERSION = '2.51'; 254our $VERSION = '2.55';
253our $MODEL; 255our $MODEL;
254 256
255our $AUTOLOAD; 257our $AUTOLOAD;
256our @ISA; 258our @ISA;
257 259
259 261
260our @REGISTRY; 262our @REGISTRY;
261 263
262my @models = ( 264my @models = (
263 [Coro::Event:: => AnyEvent::Impl::Coro::], 265 [Coro::Event:: => AnyEvent::Impl::Coro::],
266 [EV:: => EV::AnyEvent::],
264 [Event:: => AnyEvent::Impl::Event::], 267 [Event:: => AnyEvent::Impl::Event::],
265 [Glib:: => AnyEvent::Impl::Glib::], 268 [Glib:: => AnyEvent::Impl::Glib::],
266 [Tk:: => AnyEvent::Impl::Tk::], 269 [Tk:: => AnyEvent::Impl::Tk::],
267 [AnyEvent::Impl::Perl:: => AnyEvent::Impl::Perl::], 270 [AnyEvent::Impl::Perl:: => AnyEvent::Impl::Perl::],
268); 271);
386 or Carp::croak "required option 'pid' is missing"; 389 or Carp::croak "required option 'pid' is missing";
387 390
388 $PID_CB{$pid}{$arg{cb}} = $arg{cb}; 391 $PID_CB{$pid}{$arg{cb}} = $arg{cb};
389 392
390 unless ($WNOHANG) { 393 unless ($WNOHANG) {
391 $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_child_wait);
392 $WNOHANG = eval { require POSIX; &POSIX::WNOHANG } || 1; 394 $WNOHANG = eval { require POSIX; &POSIX::WNOHANG } || 1;
393 } 395 }
394 396
397 unless ($CHLD_W) {
398 $CHLD_W = AnyEvent->signal (signal => 'CHLD', cb => \&_child_wait);
395 # child could be a zombie already 399 # child could be a zombie already
396 $PID_IDLE ||= AnyEvent->timer (after => 0, cb => \&_child_wait); 400 $PID_IDLE ||= AnyEvent->timer (after => 0, cb => \&_child_wait);
401 }
397 402
398 bless [$pid, $arg{cb}], "AnyEvent::Base::Child" 403 bless [$pid, $arg{cb}], "AnyEvent::Base::Child"
399} 404}
400 405
401sub AnyEvent::Base::Child::DESTROY { 406sub AnyEvent::Base::Child::DESTROY {
437I<rxvt-unicode> distribution. 442I<rxvt-unicode> distribution.
438 443
439I<rxvt-unicode> also cheats a bit by not providing blocking access to 444I<rxvt-unicode> also cheats a bit by not providing blocking access to
440condition variables: code blocking while waiting for a condition will 445condition variables: code blocking while waiting for a condition will
441C<die>. This still works with most modules/usages, and blocking calls must 446C<die>. This still works with most modules/usages, and blocking calls must
442not be in an interactive appliation, so it makes sense. 447not be in an interactive application, so it makes sense.
443 448
444=head1 ENVIRONMENT VARIABLES 449=head1 ENVIRONMENT VARIABLES
445 450
446The following environment variables are used by this module: 451The following environment variables are used by this module:
447 452

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines