X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FStem%2FEvent.pm;h=3d1f11403ba13c1693739dc4cf1a46547a4b6388;hb=56f74ebb051e474ced234286cd79303f3e9cd14c;hp=bd80857795a4a85e8de919feef95a9d6fe7e8e27;hpb=4536f6551e07988483a419d1094bdbe80a77b322;p=urisagit%2FStem.git diff --git a/lib/Stem/Event.pm b/lib/Stem/Event.pm index bd80857..3d1f114 100644 --- a/lib/Stem/Event.pm +++ b/lib/Stem/Event.pm @@ -64,15 +64,12 @@ my %loop_to_class = ( my $loop_class = _get_loop_class() ; -init_loop() ; +INIT{ init_loop() ; } sub init_loop { $loop_class->_init_loop() ; - -Stem::Event::Queue::_init_queue() if defined &Stem::Event::Queue::_init_queue ; - } sub start_loop { @@ -295,19 +292,25 @@ sub _get_loop_class { $loop_type = 'perl' unless $loop_to_class{ $loop_type } ; my $loop_class = "Stem::Event::$loop_to_class{ $loop_type }" ; +#print "LOOP $loop_class\n" ; + unless ( eval "require $loop_class" ) { die "can't load $loop_class: $@" if $@ && $@ !~ /locate/ ; +print "not found\n" ; + $loop_type = 'perl' ; eval { require Stem::Event::Perl } ; die "can't load event loop Stem::Event::Perl $@" if $@ ; } + # save the event loop that we loaded. #print "using event loop [$loop_type]\n" ; $Stem::Vars::Env{ 'event_loop' } = $loop_type ; + return $loop_class ; } @@ -315,10 +318,7 @@ sub _get_loop_class { ############################################################################ package Stem::Event::Plain ; - -BEGIN { - @Stem::Event::Plain::ISA = qw( Stem::Event ) ; -} +our @ISA = qw( Stem::Event ) ; =head2 Stem::Event::Plain::new @@ -365,7 +365,7 @@ sub new { my $self = Stem::Class::parse_args( $attr_spec_plain, @_ ) ; return $self unless ref $self ; - my $err = $self->_core_event_build( 'plain' ) ; + my $err = $self->_build_core_event( 'plain' ) ; return $err if $err ; return $self ; @@ -374,8 +374,7 @@ sub new { ############################################################################ package Stem::Event::Signal ; - -BEGIN { our @ISA = qw( Stem::Event ) } ; +our @ISA = qw( Stem::Event ) ; =head2 Stem::Event::Signal::new @@ -461,8 +460,7 @@ sub new { ############################################################################ package Stem::Event::Timer ; - -BEGIN { our @ISA = qw( Stem::Event ) } ; +our @ISA = qw( Stem::Event ) ; =head2 Stem::Event::Timer::new @@ -651,8 +649,7 @@ sub timer_triggered { # these override Stem::Event's methods and then call those via SUPER:: package Stem::Event::IO ; - -BEGIN { our @ISA = qw( Stem::Event ) } ; +our @ISA = qw( Stem::Event ) ; sub init_io_timeout { @@ -725,8 +722,7 @@ sub timed_out { ####################################################### package Stem::Event::Read ; - -BEGIN { our @ISA = qw( Stem::Event::IO ) } +our @ISA = qw( Stem::Event::IO ) ; =head2 Stem::Event::Read::new @@ -808,6 +804,7 @@ sub new { my $self = Stem::Class::parse_args( $attr_spec_read, @_ ) ; return $self unless ref $self ; + # return <{fh} ; # Stem::Event::Read: $self->{fh} is not an open handle # ERR @@ -824,8 +821,7 @@ sub new { ############################################################################ package Stem::Event::Write ; - -BEGIN { our @ISA = qw( Stem::Event::IO ) } ; +our @ISA = qw( Stem::Event::IO ) ; =head2 Stem::Event::Write::new