--- AnyEvent/lib/AnyEvent.pm 2006/10/30 20:52:24 1.14 +++ AnyEvent/lib/AnyEvent.pm 2006/12/10 21:33:33 1.18 @@ -159,6 +159,28 @@ =back +=head1 GLOBALS + +=over 4 + +=item $AnyEvent::MODEL + +Contains C until the first watcher is being created. Then it +contains the event model that is being used, which is the name of the +Perl class implementing the model. This class is usually one of the +C modules, but can be any other class in the case +AnyEvent has been extended at runtime (e.g. in I). + +The known classes so far are: + + AnyEvent::Impl::Coro based on Coro::Event, best choise. + AnyEvent::Impl::Event based on Event, also best choice :) + AnyEvent::Impl::Glib based on Glib, second-best choice. + AnyEvent::Impl::Tk based on Tk, very bad choice. + AnyEvent::Impl::Perl pure-perl implementation, inefficient. + +=back + =head1 WHAT TO DO IN A MODULE As a module author, you should "use AnyEvent" and call AnyEvent methods @@ -197,7 +219,7 @@ use strict 'vars'; use Carp; -our $VERSION = '1.02'; +our $VERSION = '2.1'; our $MODEL; our $AUTOLOAD; @@ -208,20 +230,20 @@ our @REGISTRY; my @models = ( - [Coro::Event:: => AnyEvent::Impl::Coro::], - [Event:: => AnyEvent::Impl::Event::], - [Glib:: => AnyEvent::Impl::Glib::], - [Tk:: => AnyEvent::Impl::Tk::], - [AnyEvent::Impl::Perl:: => AnyEvent::Impl::Perl::], + [Coro::Event:: => AnyEvent::Impl::Coro::], + [Event:: => AnyEvent::Impl::Event::], + [Glib:: => AnyEvent::Impl::Glib::], + [Tk:: => AnyEvent::Impl::Tk::], + [AnyEvent::Impl::Perl:: => AnyEvent::Impl::Perl::], ); our %method = map +($_ => 1), qw(io timer condvar broadcast wait DESTROY); sub AUTOLOAD { - $AUTOLOAD =~ s/.*://; + (my $func = $AUTOLOAD) =~ s/.*://; - $method{$AUTOLOAD} - or croak "$AUTOLOAD: not a valid method for AnyEvent objects"; + $method{$func} + or croak "$func: not a valid method for AnyEvent objects"; unless ($MODEL) { # check for already loaded models @@ -256,7 +278,7 @@ @ISA = $MODEL; my $class = shift; - $class->$AUTOLOAD (@_); + $class->$func (@_); } =head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE