projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
change the max number of days to search for spots to 100
[spider.git]
/
perl
/
Timer.pm
diff --git
a/perl/Timer.pm
b/perl/Timer.pm
index 8969756f550706bb942e7bc3e7c6f2bb93054841..281421f08d72394b13c54912d97fbb476d3ae0ba 100644
(file)
--- a/
perl/Timer.pm
+++ b/
perl/Timer.pm
@@
-10,9
+10,11
@@
package Timer;
package Timer;
-use vars qw(@timerchain);
+use vars qw(@timerchain $notimers);
+use DXDebug;
@timerchain = ();
@timerchain = ();
+$notimers = 0;
sub new
{
sub new
{
@@
-22,15
+24,16
@@
sub new
my $self = bless { t=>$time + time, proc=>$proc }, $class;
$self->{interval} = $time if $recur;
push @timerchain, $self;
my $self = bless { t=>$time + time, proc=>$proc }, $class;
$self->{interval} = $time if $recur;
push @timerchain, $self;
+ $notimers++;
+ dbg('connll', "Timer created ($notimers)");
return $self;
}
sub del
{
my $self = shift;
return $self;
}
sub del
{
my $self = shift;
-
my $old =
delete $self->{proc};
+ delete $self->{proc};
@timerchain = grep {$_ != $self} @timerchain;
@timerchain = grep {$_ != $self} @timerchain;
- return $old;
}
sub handler
}
sub handler
@@
-38,12
+41,18
@@
sub handler
my $now = time;
# handle things on the timer chain
my $now = time;
# 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};
}
}
}
}
}
}
+sub DESTROY
+{
+ dbg('connll', "timer destroyed ($Timer::notimers)");
+ $Timer::notimers--;
+}
1;
1;