2 # Polled Timer handling
4 # This uses callbacks. BE CAREFUL!!!!
8 # Copyright (c) 2001 Dirk Koopman G1TLH
13 use vars qw(@timerchain $notimers);
21 my ($pkg, $time, $proc, $recur) = @_;
23 my $class = $obj || $pkg;
24 my $self = bless { t=>$time + time, proc=>$proc }, $class;
25 $self->{interval} = $time if $recur;
26 push @timerchain, $self;
28 dbg('connll', "Timer created ($notimers)");
36 @timerchain = grep {$_ != $self} @timerchain;
43 # handle things on the timer chain
45 foreach $t (@timerchain) {
46 if ($now >= $t->{t}) {
48 $t->{t} = $now + $t->{interval} if exists $t->{interval};
55 dbg('connll', "timer destroyed ($Timer::notimers)");