X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FTimer.pm;h=fb429f643537d40cd204b367c93ed5f962cd74df;hb=68fa2f8ae34d78464cb196851a7ce09ebef61b1b;hp=281421f08d72394b13c54912d97fbb476d3ae0ba;hpb=a6e52cc1680c2c30ef874e2e6c16d00c956624ee;p=spider.git diff --git a/perl/Timer.pm b/perl/Timer.pm index 281421f0..fb429f64 100644 --- a/perl/Timer.pm +++ b/perl/Timer.pm @@ -3,19 +3,21 @@ # # This uses callbacks. BE CAREFUL!!!! # -# $Id$ +# # # Copyright (c) 2001 Dirk Koopman G1TLH # package Timer; -use vars qw(@timerchain $notimers); +use vars qw(@timerchain $notimers $lasttime); use DXDebug; @timerchain = (); $notimers = 0; +$lasttime = 0; + sub new { my ($pkg, $time, $proc, $recur) = @_; @@ -25,7 +27,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; } @@ -39,7 +41,9 @@ sub del sub handler { my $now = time; - + + return unless $now != $lasttime; + # handle things on the timer chain my $t; foreach $t (@timerchain) { @@ -48,11 +52,13 @@ sub handler $t->{t} = $now + $t->{interval} if exists $t->{interval}; } } + + $lasttime = $now; } sub DESTROY { - dbg('connll', "timer destroyed ($Timer::notimers)"); + dbg("timer destroyed ($Timer::notimers)") if isdbg('connll'); $Timer::notimers--; } 1;