Last active
June 22, 2016 01:19
-
-
Save brianmed/4166e7acdf5c850502b463a597d20a77 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(0 => sub { say 'zero' }); | |
Mojo::IOLoop->delay( | |
sub { | |
my $delay = shift; | |
my $next = $delay->pass('B')->begin; | |
Mojo::IOLoop->timer(1 => sub { say 'one'; $next->() }); | |
}, | |
sub { | |
my ($delay, $value) = @_; | |
my $next = $delay->pass('C')->begin; | |
Mojo::IOLoop->timer(1 => sub { say "two: $value"; $next->() }); | |
}, | |
sub { | |
my ($delay, $value) = @_; | |
my $next = $delay->pass('D')->begin; | |
Mojo::IOLoop->timer(1 => sub { say "three: $value"; $next->() }); | |
}, | |
sub { | |
my ($delay, $value) = @_; | |
my $end = $delay->begin; | |
Mojo::IOLoop->timer(1 => sub { say "four: $value"; $end->() }); | |
} | |
)->wait; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment