Created
June 21, 2016 22:21
-
-
Save brianmed/9aa9ff6da65e17fd0e32178b26d7a8ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojo::Base -strict; | |
use Mojo::IOLoop; | |
Mojo::IOLoop->timer(3.3 => sub { | |
say ("Worked!!"); | |
}); | |
Mojo::IOLoop->delay( | |
# First step (simple timer) | |
sub { | |
my $delay = shift; | |
Mojo::IOLoop->timer(2 => $delay->begin); | |
say 'Second step in 2 seconds.'; | |
}, | |
# Second step (concurrent timers) | |
sub { | |
my $delay = shift; | |
Mojo::IOLoop->timer(1 => $delay->begin); | |
Mojo::IOLoop->timer(3 => $delay->begin); | |
say 'Third step in 3 seconds.'; | |
}, | |
# Third step (the end) | |
sub { say 'And done after 5 seconds total.' } | |
)->wait; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment