stop the Timer::handler searching its chain more than once a second
[spider.git] / perl / Timer.pm
index 683497d2d328f889f6d1ac6f1aaf9538587b3a4a..fc1103159d2150cd3a9468669abfc3f226fc568c 100644 (file)
@@ -16,6 +16,14 @@ 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,0));
+$main::build += $VERSION;
+$main::branch += $BRANCH;
+
+my $lasttime = 0;
+
 sub new
 {
     my ($pkg, $time, $proc, $recur) = @_;
@@ -39,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) {
@@ -48,6 +58,8 @@ sub handler
                        $t->{t} = $now + $t->{interval} if exists $t->{interval};
                }
        }
+
+       $lasttime = $now;
 }
 
 sub DESTROY