$loop_class->_init_loop() ;
-Stem::Event::Queue::_init_queue() if defined &Stem::Event::Queue::_init_queue ;
+#Stem::Event::Queue::_init_queue() if defined &Stem::Event::Queue::_init_queue ;
}
package Stem::Event::Plain ;
-BEGIN {
- @Stem::Event::Plain::ISA = qw( Stem::Event ) ;
-}
+our @ISA = qw( Stem::Event ) ;
=head2 Stem::Event::Plain::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 ;
package Stem::Event::Signal ;
-BEGIN { our @ISA = qw( Stem::Event ) } ;
+our @ISA = qw( Stem::Event ) ;
=head2 Stem::Event::Signal::new
package Stem::Event::Timer ;
-BEGIN { our @ISA = qw( Stem::Event ) } ;
+our @ISA = qw( Stem::Event ) ;
=head2 Stem::Event::Timer::new
package Stem::Event::IO ;
-BEGIN { our @ISA = qw( Stem::Event ) } ;
+our @ISA = qw( Stem::Event ) ;
sub init_io_timeout {
package Stem::Event::Read ;
-BEGIN { our @ISA = qw( Stem::Event::IO ) }
+our @ISA = qw( Stem::Event::IO ) ;
=head2 Stem::Event::Read::new
package Stem::Event::Write ;
-BEGIN { our @ISA = qw( Stem::Event::IO ) } ;
+our @ISA = qw( Stem::Event::IO ) ;
=head2 Stem::Event::Write::new
use Socket;
use IO::Handle ;
-use base 'Exporter' ;
-our @EXPORT = qw( &mark_not_empty ) ;
+my( $self, $queue_read, $queue_write, $queue_read_event, $queue_has_event ) ;
-my( $queue_read, $queue_write, $queue_read_event ) ;
+sub _init_event_queue {
-my $self ;
+ return if $self ;
-sub _init_queue {
+ $self = bless {} ;
socketpair( $queue_read, $queue_write,
AF_UNIX, SOCK_STREAM, PF_UNSPEC ) || die <<DIE ;
#print fileno( $queue_read ), " FILENO\n" ;
- $self = bless {} ;
$queue_read->blocking( 0 ) ;
$queue_read_event = Stem::Event::Read->new(
}
-my $queue_is_marked ;
-
-sub mark_not_empty {
+sub queue_has_event {
my( $always_mark ) = @_ ;
# don't mark the queue if it is already marked and we aren't forced
# the signal queue always marks the queue
- return if $queue_is_marked && !$always_mark ;
+ return if $queue_has_event && !$always_mark ;
syswrite( $queue_write, 'x' ) ;
- $queue_is_marked = 1 ;
+ $queue_has_event = 1 ;
}
sub readable {
sysread( $queue_read, my $buf, 10 ) ;
- $queue_is_marked = 0 ;
+ $queue_has_event = 0 ;
# Stem::Event::Plain::process_queue();
Stem::Event::Signal::process_signal_queue();
$SIG{ $signal } = $cached_handlers{$signal} ||=
sub {
- mark_not_empty() ;
+ Stem::Event::Queue::queue_has_event() ;
+
#print "HIT $signal\n";
push @signal_queue, $signal
} ;
$signal2event{$signal} = $self ;
#print "$signal = $SIG{ $signal }\n" ;
+
+# make sure the event queue is set up so we can handle signals in the
+# event loop
+
+ Stem::Event::Queue::_init_event_queue() ;
+
return ;
}
use strict ;
-#use Test::More tests => 29 ;
-use Test::More tests => 24 ;
+use Test::More tests => 27 ;
use Symbol ;
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 () ;