X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FTimer.pm;h=98132dec6578345a4b955b02af7eae67e5296377;hb=dbc63738d8b497c03bfb81c84e61161bb5c7931a;hp=0c44278e05067723a8d0a5e25df430af2ada801c;hpb=2f1b948ea733e0ece1909a31987dc8f03044e851;p=spider.git diff --git a/perl/Timer.pm b/perl/Timer.pm index 0c44278e..98132dec 100644 --- a/perl/Timer.pm +++ b/perl/Timer.pm @@ -16,6 +16,12 @@ use DXDebug; @timerchain = (); $notimers = 0; +use vars qw($VERSION $BRANCH); +$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); +$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ ) || 0; +$main::build += $VERSION; +$main::branch += $BRANCH; + sub new { my ($pkg, $time, $proc, $recur) = @_; @@ -25,7 +31,7 @@ sub new $self->{interval} = $time if $recur; push @timerchain, $self; $notimers++; - dbg('connll', "Timer created ($notimers)"); + dbg("Timer created ($notimers)") if isdbg('connll'); return $self; } @@ -41,17 +47,18 @@ sub handler my $now = time; # handle things on the timer chain - for (@timerchain) { - if ($now >= $_->{t}) { - &{$_->{proc}}(); - $_->{t} = $now + $_->{interval} if exists $_->{interval}; + my $t; + foreach $t (@timerchain) { + if ($now >= $t->{t}) { + &{$t->{proc}}(); + $t->{t} = $now + $t->{interval} if exists $t->{interval}; } } } sub DESTROY { - dbg('connll', "Timer destroyed ($notimers)"); - $notimers--; + dbg("timer destroyed ($Timer::notimers)") if isdbg('connll'); + $Timer::notimers--; } 1;