X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FStem%2FEvent%2FQueue.pm;fp=lib%2FStem%2FEvent%2FQueue.pm;h=53db4fa99767ccab423a35b3d7eb5b82b52ac286;hb=4932dd97955faf49e7777420bb2fb196db7cb92a;hp=e6549d93e51e4170927c50ff2796399d10978f34;hpb=4536f6551e07988483a419d1094bdbe80a77b322;p=urisagit%2FStem.git diff --git a/lib/Stem/Event/Queue.pm b/lib/Stem/Event/Queue.pm index e6549d9..53db4fa 100644 --- a/lib/Stem/Event/Queue.pm +++ b/lib/Stem/Event/Queue.pm @@ -48,14 +48,13 @@ use warnings ; 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 <blocking( 0 ) ; $queue_read_event = Stem::Event::Read->new( @@ -78,27 +76,25 @@ DIE } -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();