Fixed in source. Will be in next release.
--
Paul Evans
=== 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" );