From: Uri Guttman Date: Wed, 9 Sep 2009 21:51:27 +0000 (-0400) Subject: fixed gitignore X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f4d1dc84704fc932aa1bcdcce518baffa59e6d55;p=urisagit%2FStem.git fixed gitignore working on test bugs fixed event test driver known issue with signal event initialization in Perl.pm --- diff --git a/.gitignore b/.gitignore index 403a422..ec302ab 100644 --- a/.gitignore +++ b/.gitignore @@ -10,13 +10,28 @@ MANIFEST.bak _build/ Build Makefile -lib/ blib/ # Temp, old and emacs backup files. *~ *.old +old* \#*# .#* .*.swp +lib-pod +*.ok +modules + +event_test +*.gz +dlug +flow +intel +pod +scaffidi +slides +stem2pod +test + diff --git a/lib/Stem/Event.pm b/lib/Stem/Event.pm index bd80857..1df1a00 100644 --- a/lib/Stem/Event.pm +++ b/lib/Stem/Event.pm @@ -64,14 +64,15 @@ my %loop_to_class = ( my $loop_class = _get_loop_class() ; -init_loop() ; +INIT{ init_loop() ; } sub init_loop { +Stem::Event::Queue::_init_queue() if defined &Stem::Event::Queue::_init_queue ; + $loop_class->_init_loop() ; -Stem::Event::Queue::_init_queue() if defined &Stem::Event::Queue::_init_queue ; } @@ -295,19 +296,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 +322,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 +369,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 +378,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 +464,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 +653,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 +726,9 @@ sub timed_out { ####################################################### package Stem::Event::Read ; +our @ISA = qw( Stem::Event::IO ) ; +print "B @ISA\n" ; -BEGIN { our @ISA = qw( Stem::Event::IO ) } =head2 Stem::Event::Read::new @@ -804,10 +806,12 @@ HELP sub new { my( $class ) = shift ; +print "@ISA\n" ; 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 +828,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 diff --git a/lib/Stem/Event/Perl.pm b/lib/Stem/Event/Perl.pm index f614da7..6974027 100644 --- a/lib/Stem/Event/Perl.pm +++ b/lib/Stem/Event/Perl.pm @@ -35,12 +35,11 @@ API for the standard classes: =cut package Stem::Event::Perl ; +our @ISA = qw( Stem::Event ) ; use strict ; use Stem::Event::Signal ; -@Stem::Event::Perl::ISA = qw( Stem::Event ) ; - BEGIN { unless ( eval { require Time::HiRes } ) { diff --git a/lib/Stem/Event/Queue.pm b/lib/Stem/Event/Queue.pm index e6549d9..241bba3 100644 --- a/lib/Stem/Event/Queue.pm +++ b/lib/Stem/Event/Queue.pm @@ -41,6 +41,7 @@ package Stem::Event::Queue ; +our @ISA = qw( Stem::Event ) ; use strict ; use warnings ; @@ -49,7 +50,7 @@ use Socket; use IO::Handle ; use base 'Exporter' ; -our @EXPORT = qw( &mark_not_empty ) ; +our @EXPORT = qw( mark_not_empty ) ; my( $queue_read, $queue_write, $queue_read_event ) ; diff --git a/lib/Stem/Event/Signal.pm b/lib/Stem/Event/Signal.pm index c9d723e..14a85ba 100644 --- a/lib/Stem/Event/Signal.pm +++ b/lib/Stem/Event/Signal.pm @@ -32,8 +32,8 @@ sub _build { $SIG{ $signal } = $cached_handlers{$signal} ||= sub { - mark_not_empty() ; -#print "HIT $signal\n"; +print "HIT $signal\n"; + Stem::Event::Queue::mark_not_empty() ; push @signal_queue, $signal } ; diff --git a/t/event/event_test.pl b/t/event/event_test.pl index 11227d1..faefbfe 100644 --- a/t/event/event_test.pl +++ b/t/event/event_test.pl @@ -11,8 +11,7 @@ BEGIN { use strict ; -#use Test::More tests => 29 ; -use Test::More tests => 24 ; +use Test::More tests => 27 ; use Symbol ; @@ -27,9 +26,9 @@ exit ; sub test_events { -# test_null_events() ; -# test_plain_events () ; -# test_signal_events () ; + test_null_events() ; + test_plain_events () ; + test_signal_events () ; test_hard_timer_events () ; test_soft_timer_events () ; test_io_events () ; @@ -65,6 +64,7 @@ sub triggered { my( $self ) = @_ ; ok( 1, 'plain event triggered' ) ; + Stem::Event::stop_loop() ; } sub test_signal_events { @@ -76,6 +76,22 @@ sub test_signal_events { return ; } + my $event2 = Stem::Event::Timer->new( + 'object' => $self, + 'method' => 'send_int_signal', + 'delay' => 3, + ) ; + + ok( ref $event2, 'signal delay timer created' ) ; + + Stem::Event::start_loop() ; + + ok( 1, 'signal - event loop exit' ) ; + } +} + +sub send_int_signal { + my $event = Stem::Event::Signal->new( 'object' => $self, 'signal' => 'INT', @@ -85,14 +101,10 @@ sub test_signal_events { $self->{'sig_event'} = $event ; - kill 'INT', $$ ; - -#print "kill INT\n" ; - Stem::Event::start_loop() ; +print "kill INT\n" ; - ok( 1, 'signal - event loop exit' ) ; - } + kill 'INT', $$ ; } # callback method for signal @@ -142,6 +154,8 @@ sub hard_timeout { my( $self ) = @_ ; +send_int_signal() ; + ok( 1, 'hard timer event triggered' ) ; if ( --$self->{'hard_timer_count'} > 0 ) {