Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
better reactor example for Mojo::IOLoop
  • Loading branch information
kraih committed Oct 17, 2012
1 parent 0ad9418 commit 0eb2e5f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Mojo/IOLoop.pm
Expand Up @@ -412,12 +412,15 @@ Number of connections to accept at once, defaults to C<50>.
Low level event reactor, usually a L<Mojo::Reactor::Poll> or
L<Mojo::Reactor::EV> object.
# Watch handle for I/O events
# Watch if handle becomes readable or writable
$loop->reactor->io($handle => sub {
my ($reactor, $writable) = @_;
say $writable ? 'Handle is writable' : 'Handle is readable';
});
# Change to watching only if handle becomes writable
$loop->reactor->watch($handle, 0, 1);
=head2 C<unlock>
my $cb = $loop->unlock;
Expand Down

0 comments on commit 0eb2e5f

Please sign in to comment.