Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test next_tick return value
  • Loading branch information
kraih committed Feb 26, 2014
1 parent da4b800 commit b3ddfb5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
27 changes: 23 additions & 4 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -501,6 +501,12 @@ Check if event loop is running.
Invoke callback as soon as possible, but not before returning, always returns
C<undef>.
# Perform operation on next reactor tick
Mojo::IOLoop->next_tick(sub {
my $loop = shift;
...
});
=head2 one_tick
Mojo::IOLoop->one_tick;
Expand All @@ -516,12 +522,19 @@ into the reactor, so you need to be careful.
=head2 recurring
my $id = Mojo::IOLoop->recurring(0.5 => sub {...});
my $id = $loop->recurring(3 => sub {...});
my $id = Mojo::IOLoop->recurring(3 => sub {...});
my $id = $loop->recurring(0 => sub {...});
my $id = $loop->recurring(0.25 => sub {...});
Create a new recurring timer, invoking the callback repeatedly after a given
amount of time in seconds.
# Perform operation every 5 seconds
Mojo::IOLoop->recurring(5 => sub {
my $loop = shift;
...
});
=head2 remove
Mojo::IOLoop->remove($id);
Expand Down Expand Up @@ -592,13 +605,19 @@ Get L<Mojo::IOLoop::Stream> object for id or turn object into a connection.
=head2 timer
my $id = Mojo::IOLoop->timer(5 => sub {...});
my $id = $loop->timer(5 => sub {...});
my $id = Mojo::IOLoop->timer(3 => sub {...});
my $id = $loop->timer(0 => sub {...});
my $id = $loop->timer(0.25 => sub {...});
Create a new timer, invoking the callback after a given amount of time in
seconds.
# Perform operation in 5 seconds
Mojo::IOLoop->timer(5 => sub {
my $loop = shift;
...
});
=head1 DEBUGGING
You can set the MOJO_IOLOOP_DEBUG environment variable to get some advanced
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/reactor_ev.t
Expand Up @@ -135,7 +135,7 @@ ok !$timer, 'timer was not triggered';
ok $recurring, 'recurring was triggered again';
$reactor->remove($id);
($readable, $writable, $timer, $recurring) = ();
$reactor->next_tick(sub { shift->stop });
is $reactor->next_tick(sub { shift->stop }), undef, 'returned undef';
$reactor->start;
ok $readable, 'handle is readable again';
ok $writable, 'handle is writable again';
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/reactor_poll.t
Expand Up @@ -133,7 +133,7 @@ ok !$timer, 'timer was not triggered';
ok $recurring, 'recurring was triggered again';
$reactor->remove($id);
($readable, $writable, $timer, $recurring) = ();
$reactor->next_tick(sub { shift->stop });
is $reactor->next_tick(sub { shift->stop }), undef, 'returned undef';
$reactor->start;
ok $readable, 'handle is readable again';
ok $writable, 'handle is writable again';
Expand Down

0 comments on commit b3ddfb5

Please sign in to comment.