2 # Polled Timer handling
4 # This uses callbacks. BE CAREFUL!!!!
8 # Copyright (c) 2001 Dirk Koopman G1TLH
13 use vars qw(@timerchain $notimers $lasttime);
23 my ($pkg, $time, $proc, $recur) = @_;
25 my $class = $obj || $pkg;
26 my $self = bless { t=>$time + $main::systime, proc=>$proc }, $class;
27 $self->{interval} = $time if $recur;
28 push @timerchain, $self;
29 $notimers = @timerchain;
30 dbg("Timer created (notimers: $notimers)") if isdbg('connll');
38 @timerchain = grep {$_ != $self} @timerchain;
39 $notimers = @timerchain;
40 dbg("Timer deleted (notimers: $notimers)") if isdbg('connll');
45 my $now = $main::systime;
47 return unless $now != $lasttime;
49 # handle things on the timer chain
51 foreach $t (@timerchain) {
52 if ($now >= $t->{t}) {
54 $t->{t} = $now + $t->{interval} if exists $t->{interval};
63 dbg("timer destroyed ($Timer::notimers)") if isdbg('connll');