Skip Menu |

This queue is for tickets about the IO-Async CPAN distribution.

Report information
The Basics
Id: 75571
Status: resolved
Priority: 0/
Queue: IO-Async

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.46
Fixed in:
  • 0.46_001
  • 0.47



Subject: Timer->stop ought never error
If a timer isn't running, or isn't in a loop, it ought still be OK to - Show quoted text
>stop it. Just ignore the request.
Also timers should be stopped when removed. -- Paul Evans
Fixed in source. Will be in next release. -- Paul Evans
Subject: rt75571.patch
=== modified file 'lib/IO/Async/Timer.pm' --- lib/IO/Async/Timer.pm 2012-03-02 11:45:47 +0000 +++ lib/IO/Async/Timer.pm 2012-03-12 18:32:25 +0000 @@ -167,6 +167,8 @@ return; } + return if !$self->is_running; + my $loop = $self->loop or croak "Cannot stop a Timer that is not in a Loop"; defined $self->{id} or return; # nothing to do but no error === modified file 't/22timer-countdown.t' --- t/22timer-countdown.t 2011-11-25 16:54:55 +0000 +++ t/22timer-countdown.t 2012-03-12 18:32:25 +0000 @@ -4,7 +4,7 @@ use IO::Async::Test; -use Test::More tests => 53; +use Test::More tests => 54; use Test::Fatal; use Test::Refcount; @@ -104,6 +104,10 @@ $timer->stop; + $timer->stop; + + ok( 1, "Timer can be stopped a second time" ); + $loop->loop_once( 2 * AUT ); ok( !$expired, "Stopped timer doesn't expire" ); === modified file 't/22timer-periodic.t' --- t/22timer-periodic.t 2011-11-23 23:45:41 +0000 +++ t/22timer-periodic.t 2012-03-12 18:32:25 +0000 @@ -4,7 +4,7 @@ use IO::Async::Test; -use Test::More tests => 36; +use Test::More tests => 37; use Test::Fatal; use Test::Refcount; @@ -76,6 +76,10 @@ $timer->stop; + $timer->stop; + + ok( 1, "Timer can be stopped a second time" ); + $loop->loop_once( 2 * AUT ); ok( $tick == 2, "Stopped timer doesn't tick" );