projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add standard gcommit command
[spider.git]
/
perl
/
Timer.pm
diff --git
a/perl/Timer.pm
b/perl/Timer.pm
index 0c44278e05067723a8d0a5e25df430af2ada801c..60ef387717f74700569c72efcb3a88b6f3e2932a 100644
(file)
--- a/
perl/Timer.pm
+++ b/
perl/Timer.pm
@@
-10,12
+10,14
@@
package Timer;
package Timer;
-use vars qw(@timerchain $notimers);
+use vars qw(@timerchain $notimers
$lasttime
);
use DXDebug;
@timerchain = ();
$notimers = 0;
use DXDebug;
@timerchain = ();
$notimers = 0;
+$lasttime = 0;
+
sub new
{
my ($pkg, $time, $proc, $recur) = @_;
sub new
{
my ($pkg, $time, $proc, $recur) = @_;
@@
-25,7
+27,7
@@
sub new
$self->{interval} = $time if $recur;
push @timerchain, $self;
$notimers++;
$self->{interval} = $time if $recur;
push @timerchain, $self;
$notimers++;
- dbg(
'connll', "Timer created ($notimers)"
);
+ dbg(
"Timer created ($notimers)") if isdbg('connll'
);
return $self;
}
return $self;
}
@@
-39,19
+41,24
@@
sub del
sub handler
{
my $now = time;
sub handler
{
my $now = time;
-
+
+ return unless $now != $lasttime;
+
# handle things on the timer chain
# 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};
}
}
}
}
+
+ $lasttime = $now;
}
sub DESTROY
{
}
sub DESTROY
{
- dbg(
'connll', "Timer destroyed ($notimers)"
);
- $notimers--;
+ dbg(
"timer destroyed ($Timer::notimers)") if isdbg('connll'
);
+ $
Timer::
notimers--;
}
1;
}
1;