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 + time, proc=>$proc }, $class;
27 $self->{interval} = $time if $recur;
28 push @timerchain, $self;
30 dbg("Timer created ($notimers)") if isdbg('connll');
38 @timerchain = grep {$_ != $self} @timerchain;
45 return unless $now != $lasttime;
47 # handle things on the timer chain
49 foreach $t (@timerchain) {
50 if ($now >= $t->{t}) {
52 $t->{t} = $now + $t->{interval} if exists $t->{interval};
61 dbg("timer destroyed ($Timer::notimers)") if isdbg('connll');