Skip to content

Commit

Permalink
fixed is_readable scalability problems in Mojo::Reactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 26, 2014
1 parent 3ae054c commit cccc50a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@

5.19 2014-07-26
- Improved support for Unicode anchors in Mojolicious::Plugin::PODRenderer.
- Fixed is_readable scalability problems in Mojo::Reactor.

5.18 2014-07-25
- Improved is_readable performance in Mojo::Reactor.
Expand Down
8 changes: 3 additions & 5 deletions lib/Mojo/Reactor.pm
Expand Up @@ -2,6 +2,7 @@ package Mojo::Reactor;
use Mojo::Base 'Mojo::EventEmitter';

use Carp 'croak';
use IO::Poll qw(POLLIN POLLPRI);
use Mojo::Loader;

sub again { croak 'Method "again" not implemented by subclass' }
Expand All @@ -13,11 +14,8 @@ sub detect {

sub io { croak 'Method "io" not implemented by subclass' }

sub is_readable {
my ($self, $handle) = @_;
vec(my $read, fileno($handle), 1) = 1;
return !!select $read, undef, $read, 0;
}
# This may break at some point in the future, but is worth it for performance
sub is_readable { !(IO::Poll::_poll(0, fileno(pop), POLLIN | POLLPRI) == 0) }

sub is_running { croak 'Method "is_running" not implemented by subclass' }

Expand Down

0 comments on commit cccc50a

Please sign in to comment.