Permalink
Browse files

more timer examples

  • Loading branch information...
1 parent a181b9a commit 77625e001d5a47642b4ee18cb2458ce4e54a8293 @kraih kraih committed May 21, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 lib/Mojo/IOLoop.pm
View
@@ -511,6 +511,9 @@ that this method can recurse back into the reactor, so you need to be careful.
Create a new recurring timer, invoking the callback repeatedly after a given
amount of time in seconds.
+ # Invoke as soon as possible
+ Mojo::IOLoop->recurring(0 => sub { say 'Reactor tick.' });
+
=head2 C<remove>
Mojo::IOLoop->remove($id);
@@ -584,6 +587,9 @@ Get L<Mojo::IOLoop::Stream> object for id or turn object into a connection.
Create a new timer, invoking the callback after a given amount of time in
seconds.
+ # Invoke as soon as possible
+ Mojo::IOLoop->timer(0 => sub { say 'Next tick.' });
+
=head1 DEBUGGING
You can set the C<MOJO_IOLOOP_DEBUG> environment variable to get some advanced

0 comments on commit 77625e0

Please sign in to comment.