Skip to content

Commit

Permalink
highlight advantage of delays more
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 15, 2014
1 parent 68d7635 commit a0b4876
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -435,9 +435,10 @@ L<Mojo::IOLoop::Client/"connect">.
my $delay = $loop->delay(sub {...});
my $delay = $loop->delay(sub {...}, sub {...});
Get L<Mojo::IOLoop::Delay> object to manage callbacks and control the flow of
events. A single callback will be treated as a subscriber to the C<finish>
event, and multiple ones as a chain of steps.
Build L<Mojo::IOLoop::Delay> object to manage callbacks and control the flow
of events, which can help you avoid deep nested closures that often result
from continuation-passing style. A single callback will be treated as a
subscriber to the C<finish> event, and multiple ones as a chain of steps.
# Synchronize multiple events
my $delay = Mojo::IOLoop->delay(sub { say 'BOOM!' });
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/IOLoop/Delay.pm
Expand Up @@ -103,7 +103,8 @@ Mojo::IOLoop::Delay - Manage callbacks and control the flow of events
=head1 DESCRIPTION
L<Mojo::IOLoop::Delay> manages callbacks and controls the flow of events for
L<Mojo::IOLoop>.
L<Mojo::IOLoop>, which can help you avoid deep nested closures that often
result from continuation-passing style.
=head1 EVENTS
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/IOLoop/Server.pm
Expand Up @@ -50,8 +50,8 @@ sub listen {
my $args = ref $_[0] ? $_[0] : {@_};

# Look for reusable file descriptor
my $port = $args->{port} || 3000;
my $address = $args->{address} || '0.0.0.0';
my $port = $args->{port} || 3000;
my $reuse = $self->{reuse} = "$address:$port";
$ENV{MOJO_REUSE} ||= '';
my $fd;
Expand Down
3 changes: 2 additions & 1 deletion lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -372,7 +372,8 @@ latency backend web services.
</html>

Multiple events such as parallel requests can be easily synchronized with
L<Mojo::IOLoop/"delay">.
L<Mojo::IOLoop/"delay">, which can help you avoid deep nested closures that
often result from continuation-passing style.

use Mojolicious::Lite;
use Mojo::IOLoop;
Expand Down
6 changes: 3 additions & 3 deletions lib/Mojolicious/Static.pm
Expand Up @@ -181,9 +181,9 @@ Serve static file for L<Mojolicious::Controller> object.
my $asset = $static->file('images/logo.png');
my $asset = $static->file('../lib/MyApp.pm');
Get L<Mojo::Asset::File> or L<Mojo::Asset::Memory> object for a file, relative
to L</"paths"> or from L</"classes">. Note that this method does not protect
from traversing to parent directories.
Build L<Mojo::Asset::File> or L<Mojo::Asset::Memory> object for a file,
relative to L</"paths"> or from L</"classes">. Note that this method does not
protect from traversing to parent directories.
my $content = $static->file('foo/bar.html')->slurp;
Expand Down

0 comments on commit a0b4876

Please sign in to comment.