2 # Polled Timer handling
4 # This uses callbacks. BE CAREFUL!!!!
8 # Copyright (c) 2001 Dirk Koopman G1TLH
13 use vars qw(@timerchain);
19 my ($pkg, $time, $proc, $recur) = @_;
21 my $class = $obj || $pkg;
22 my $self = bless { t=>$time + time, proc=>$proc }, $class;
23 $self->{interval} = $time if $recur;
24 push @timerchain, $self;
31 my $old = delete $self->{proc};
32 @timerchain = grep {$_ != $self} @timerchain;
40 # handle things on the timer chain
42 if ($now >= $_->{t}) {
44 $_->{t} = $now + $_->{interval} if exists $_->{interval};