remove 'u=' if 'o=' eq mycall
[spider.git] / perl / Timer.pm
index 281421f08d72394b13c54912d97fbb476d3ae0ba..168dd3f5fcb5490fe65e7d636b7ba401d32c34eb 100644 (file)
 
 package Timer;
 
-use vars qw(@timerchain $notimers);
+use vars qw(@timerchain $notimers $lasttime);
 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;
+
+$lasttime = 0;
+
 sub new
 {
     my ($pkg, $time, $proc, $recur) = @_;
@@ -25,7 +33,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 +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,11 +58,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;