Skip to content

Commit

Permalink
improved is_readable performance in Mojo::Reactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 25, 2014
1 parent 1924f63 commit 288c2a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

5.18 2014-07-24
5.18 2014-07-25
- Improved is_readable performance in Mojo::Reactor.

5.17 2014-07-24
- Welcome to the Mojolicious core team Jan Henning Thorsen.
Expand Down
11 changes: 2 additions & 9 deletions lib/Mojo/Reactor.pm
Expand Up @@ -2,7 +2,6 @@ package Mojo::Reactor;
use Mojo::Base 'Mojo::EventEmitter';

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

sub again { croak 'Method "again" not implemented by subclass' }
Expand All @@ -16,14 +15,8 @@ sub io { croak 'Method "io" not implemented by subclass' }

sub is_readable {
my ($self, $handle) = @_;

my $test = $self->{test} ||= IO::Poll->new;
$test->mask($handle, POLLIN | POLLPRI);
$test->poll(0);
my $result = $test->handles(POLLIN | POLLPRI | POLLERR | POLLHUP);
$test->remove($handle);

return !!$result;
vec(my $read, fileno($handle), 1) = 1;
return !!select $read, undef, $read, 0;
}

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

0 comments on commit 288c2a0

Please sign in to comment.