Skip to content

Commit

Permalink
a few more optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 27, 2013
1 parent e0e95d5 commit 9faa6b8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/Mojo/IOLoop/Stream.pm
Expand Up @@ -13,9 +13,7 @@ has timeout => 15;

sub DESTROY { shift->close }

sub new {
shift->SUPER::new(handle => shift, buffer => '', active => steady_time);
}
sub new { shift->SUPER::new(handle => shift, buffer => '') }

sub close {
my $self = shift;
Expand Down Expand Up @@ -106,11 +104,12 @@ sub _startup {
$self->{timer} = $reactor->recurring(
0.5 => sub {
return unless my $t = $self->timeout;
$self->emit_safe('timeout')->close
if (steady_time() - $self->{active}) >= $t;
return unless (steady_time() - $self->{active}) >= $t;
$self->emit_safe('timeout')->close;
}
);

$self->{active} = steady_time;
$reactor->io($self->{handle}, sub { pop() ? $self->_write : $self->_read });
}

Expand Down

0 comments on commit 9faa6b8

Please sign in to comment.