make some improvements to the console
[spider.git] / perl / Timer.pm
index 4a1e1c42e165395145eb913d124bdab2007991b9..168dd3f5fcb5490fe65e7d636b7ba401d32c34eb 100644 (file)
@@ -10,7 +10,7 @@
 
 package Timer;
 
-use vars qw(@timerchain $notimers);
+use vars qw(@timerchain $notimers $lasttime);
 use DXDebug;
 
 @timerchain = ();
@@ -22,6 +22,8 @@ $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0))
 $main::build += $VERSION;
 $main::branch += $BRANCH;
 
+$lasttime = 0;
+
 sub new
 {
     my ($pkg, $time, $proc, $recur) = @_;
@@ -45,7 +47,9 @@ sub del
 sub handler
 {
        my $now = time;
-       
+
+       return unless $now != $lasttime;
+
        # handle things on the timer chain
        my $t;
        foreach $t (@timerchain) {
@@ -54,6 +58,8 @@ sub handler
                        $t->{t} = $now + $t->{interval} if exists $t->{interval};
                }
        }
+
+       $lasttime = $now;
 }
 
 sub DESTROY