Subject: | Cancelling a timer while it is firing breaks the timequeue |
use strict;
use warnings;
use feature 'say';
use IO::Async::Loop;
my $loop = IO::Async::Loop->new;
say "Using Loop type " . ref $loop;
my $t1;
$t1 = $loop->enqueue_timer(
delay => 0,
code => sub {
warn "Cancelled t1 as $t1\n";
$loop->cancel_timer ($t1);
undef $t1;
warn "t1 fired\n";
}
);
warn "Queued t1 as $t1\n";
$loop->enqueue_timer(
delay => 0.1,
code => sub {
warn "t2 fired\n";
}
);
warn "Queued t2\n";
$loop->loop_forever;
Prints output:
Queued t1 as IO::Async::Internals::TimeQueue::Elem=ARRAY(0x18ed720)
Queued t2
Cancelled t1 as IO::Async::Internals::TimeQueue::Elem=ARRAY(0x18ed720)
t1 fired
^C
Expected
t1 fired
t2 fired
--
Paul Evans