-
-
Save niczero/ab2c950f6aa9b477ba16a16b7713f791 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
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Mojo::IOLoop; | |
get '/' => sub { | |
my $c = shift; | |
my $log = $c->app->log; | |
Mojo::IOLoop->timer(1 => sub { $log->debug('one') }); | |
Mojo::IOLoop->delay( | |
sub { | |
my ($delay) = @_; | |
my $next = $delay->begin; | |
Mojo::IOLoop->timer(0 => sub { $log->debug('zero'); $next->() }); | |
}, | |
sub { | |
my ($delay) = @_; | |
my $next = $delay->pass(2)->begin; | |
Mojo::IOLoop->timer(2 => sub { $log->debug('two'); $next->() }); | |
}, | |
sub { | |
my ($delay, $value) = @_; | |
my $next = $delay->pass(3)->begin; | |
Mojo::IOLoop->timer(1 => sub { $log->debug("three: $value"); $next->() }); | |
}, | |
sub { | |
my ($delay, $value) = @_; | |
my $next = $delay->pass(4)->begin; | |
Mojo::IOLoop->timer(1 => sub { $log->debug("four: $value"); $next->() }); | |
}, | |
sub { | |
my ($delay, $value) = @_; | |
$c->render(text => "Completed with value $value\n"); | |
} | |
); | |
return $c->render_later; | |
}; | |
app->secrets(['change me'])->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment