--- AnyEvent/lib/AnyEvent.pm 2008/07/08 23:44:51 1.167 +++ AnyEvent/lib/AnyEvent.pm 2008/07/08 23:53:37 1.168 @@ -35,11 +35,12 @@ policy> and AnyEvent is I. First and foremost, I itself, it only -interfaces to whatever event model the main program happens to use in a +interfaces to whatever event model the main program happens to use, in a pragmatic way. For event models and certain classes of immortals alike, the statement "there can only be one" is a bitter reality: In general, only one event loop can be active at the same time in a process. AnyEvent -helps hiding the differences between those event loops. +cannot change this, but it can hide the differences between those event +loops. The goal of AnyEvent is to offer module authors the ability to do event programming (waiting for I/O or timer events) without subscribing to a @@ -50,18 +51,18 @@ For modules like POE or IO::Async (which is a total misnomer as it is actually doing all I/O I...), using them in your module is like joining a cult: After you joined, you are dependent on them and you -cannot use anything else, as it is simply incompatible to everything that -isn't itself. What's worse, all the potential users of your module are -I forced to use the same event loop you use. +cannot use anything else, as they are simply incompatible to everything +that isn't them. What's worse, all the potential users of your +module are I forced to use the same event loop you use. AnyEvent is different: AnyEvent + POE works fine. AnyEvent + Glib works fine. AnyEvent + Tk works fine etc. etc. but none of these work together with the rest: POE + IO::Async? No go. Tk + Event? No go. Again: if your module uses one of those, every user of your module has to use it, too. But if your module uses AnyEvent, it works transparently with all -event models it supports (including stuff like POE and IO::Async, as long -as those use one of the supported event loops. It is trivial to add new -event loops to AnyEvent, too, so it is future-proof). +event models it supports (including stuff like IO::Async, as long as those +use one of the supported event loops. It is trivial to add new event loops +to AnyEvent, too, so it is future-proof). In addition to being free of having to use I, AnyEvent also is free of bloat and policy: with POE or similar @@ -942,12 +943,9 @@ push @{"$MODEL\::ISA"}, "AnyEvent::Base"; - if ($ENV{PERL_ANYEVENT_STRICT}) { - unshift @AnyEvent::Base::Strict::ISA, $MODEL; - unshift @ISA, AnyEvent::Base::Strict:: - } else { - unshift @ISA, $MODEL; - } + unshift @ISA, $MODEL; + + require AnyEvent::Strict if $ENV{PERL_ANYEVENT_STRICT}; (shift @post_detect)->() while @post_detect; } @@ -1123,124 +1121,6 @@ *broadcast = \&send; *wait = \&_wait; -package AnyEvent::Base::Strict; - -use Carp qw(croak); - -# supply checks for argument validity for many functions - -sub io { - my $class = shift; - my %arg = @_; - - ref $arg{cb} - or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'"; - delete $arg{cb}; - - fileno $arg{fh} - or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'"; - delete $arg{fh}; - - $arg{poll} =~ /^[rw]$/ - or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'"; - delete $arg{poll}; - - croak "AnyEvent->io called with unsupported parameter(s) " . join ", ", keys %arg - if keys %arg; - - $class->SUPER::io (@_) -} - -sub timer { - my $class = shift; - my %arg = @_; - - ref $arg{cb} - or croak "AnyEvent->timer called with illegal cb argument '$arg{cb}'"; - delete $arg{cb}; - - exists $arg{after} - or croak "AnyEvent->timer called without mandatory 'after' parameter"; - delete $arg{after}; - - $arg{interval} > 0 || !$arg{interval} - or croak "AnyEvent->timer called with illegal interval argument '$arg{interval}'"; - delete $arg{interval}; - - croak "AnyEvent->timer called with unsupported parameter(s) " . join ", ", keys %arg - if keys %arg; - - $class->SUPER::timer (@_) -} - -sub signal { - my $class = shift; - my %arg = @_; - - ref $arg{cb} - or croak "AnyEvent->signal called with illegal cb argument '$arg{cb}'"; - delete $arg{cb}; - - eval "require POSIX; defined &POSIX::SIG$arg{signal}" - or croak "AnyEvent->signal called with illegal signal name '$arg{signal}'"; - delete $arg{signal}; - - croak "AnyEvent->signal called with unsupported parameter(s) " . join ", ", keys %arg - if keys %arg; - - $class->SUPER::signal (@_) -} - -sub child { - my $class = shift; - my %arg = @_; - - ref $arg{cb} - or croak "AnyEvent->signal called with illegal cb argument '$arg{cb}'"; - delete $arg{cb}; - - $arg{pid} =~ /^-?\d+$/ - or croak "AnyEvent->signal called with illegal pid value '$arg{pid}'"; - delete $arg{pid}; - - croak "AnyEvent->signal called with unsupported parameter(s) " . join ", ", keys %arg - if keys %arg; - - $class->SUPER::child (@_) -} - -sub condvar { - my $class = shift; - my %arg = @_; - - !exists $arg{cb} or ref $arg{cb} - or croak "AnyEvent->condvar called with illegal cb argument '$arg{cb}'"; - delete $arg{cb}; - - croak "AnyEvent->condvar called with unsupported parameter(s) " . join ", ", keys %arg - if keys %arg; - - $class->SUPER::condvar (@_) -} - -sub time { - my $class = shift; - - @_ - and croak "AnyEvent->time wrongly called with paramaters"; - - $class->SUPER::time (@_) -} - -sub now { - my $class = shift; - - @_ - and croak "AnyEvent->now wrongly called with paramaters"; - - $class->SUPER::now (@_) -} - =head1 SUPPLYING YOUR OWN EVENT MODEL INTERFACE This is an advanced topic that you do not normally need to use AnyEvent in