X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=blobdiff_plain;f=lib%2FObject%2FRemote%2FMiniLoop.pm;h=faa4a38d371911d60ecfaa452447ba3f8eb5c772;hp=5be3100fa29a1c075c937ef77ea0da0e84f7c92d;hb=8c3529062a426181861d58ee59fb8f10e0be68e5;hpb=353556c4b81bcb3a0c3fff934eff5ab2f19733d4 diff --git a/lib/Object/Remote/MiniLoop.pm b/lib/Object/Remote/MiniLoop.pm index 5be3100..faa4a38 100644 --- a/lib/Object/Remote/MiniLoop.pm +++ b/lib/Object/Remote/MiniLoop.pm @@ -2,11 +2,16 @@ package Object::Remote::MiniLoop; use IO::Select; use Time::HiRes qw(time); -use Object::Remote::Logging qw( :log :dlog ); +use Object::Remote::Logging qw( :log :dlog router ); use Moo; -# this is ro because we only actually set it using local in sub run +BEGIN { + $SIG{PIPE} = sub { log_debug { "Got a PIPE signal" } }; + + router()->exclude_forwarding +} +# this is ro because we only actually set it using local in sub run has is_running => (is => 'ro', clearer => 'stop'); #maximum duration that select() will block - undef means indefinite, #0 means no blocking, otherwise maximum time in seconds @@ -93,9 +98,9 @@ sub watch_time { } elsif (exists($watch{after})) { $at = time() + $watch{after}; } elsif (exists($watch{at})) { - $at = $watch{at}; + $at = $watch{at}; } else { - die "watch_time requires every, after or at"; + die "watch_time requires every, after or at"; } die "watch_time requires code" unless my $code = $watch{code}; @@ -108,7 +113,7 @@ sub watch_time { sub unwatch_time { my ($self, $id) = @_; - log_debug { "Removing timer with id of '$id'" }; + log_trace { "Removing timer with id of '$id'" }; @$_ = grep !($_ eq $id), @$_ for $self->_timers; return; } @@ -141,8 +146,10 @@ sub loop_once { my $write_count = 0; my @c = caller; my $wait_time = $self->_next_timer_expires_delay; - log_trace { sprintf("Run loop: loop_once() has been invoked by $c[1]:$c[2] with read:%i write:%i select timeout:%s", - scalar(keys(%$read)), scalar(keys(%$write)), defined $wait_time ? $wait_time : 'indefinite' ) }; + log_trace { + sprintf("Run loop: loop_once() has been invoked by $c[1]:$c[2] with read:%i write:%i select timeout:%s", + scalar(keys(%$read)), scalar(keys(%$write)), defined $wait_time ? $wait_time : 'indefinite' ) + }; my ($readable, $writeable) = IO::Select->select( $self->_read_select, $self->_write_select, undef, $wait_time ); @@ -202,7 +209,7 @@ sub loop_once { sub want_run { my ($self) = @_; - Dlog_debug { "Run loop: Incrimenting want_running, is now $_" } + Dlog_debug { "Run loop: Incremeting want_running, is now $_" } ++$self->{want_running}; }