Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
no need to use a recurring timer for the stream timeout
  • Loading branch information
kraih committed May 10, 2013
1 parent eb0cd7d commit ab9b5d0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/IOLoop/Stream.pm
Expand Up @@ -79,8 +79,8 @@ sub timeout {
$reactor->remove(delete $self->{timer}) if $self->{timer};
return $self unless my $timeout = $self->{timeout} = shift;
weaken $self;
$self->{timer} = $reactor->recurring(
$timeout => sub { $self->emit_safe('timeout')->close });
$self->{timer}
= $reactor->timer($timeout => sub { $self->emit_safe('timeout')->close });

return $self;
}
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/reactor_ev.t
Expand Up @@ -61,7 +61,7 @@ my $server = $listen->accept;
$reactor->remove($listen);
($readable, $writable) = ();
$reactor->io($client => sub { pop() ? $writable++ : $readable++ });
$reactor->timer(0.025 => sub { shift->stop });
$reactor->again($reactor->timer(0.025 => sub { shift->stop }));
$reactor->start;
ok !$readable, 'handle is not readable';
ok $writable, 'handle is writable';
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/reactor_poll.t
Expand Up @@ -59,7 +59,7 @@ my $server = $listen->accept;
$reactor->remove($listen);
($readable, $writable) = ();
$reactor->io($client => sub { pop() ? $writable++ : $readable++ });
$reactor->timer(0.025 => sub { shift->stop });
$reactor->again($reactor->timer(0.025 => sub { shift->stop }));
$reactor->start;
ok !$readable, 'handle is not readable';
ok $writable, 'handle is writable';
Expand Down

0 comments on commit ab9b5d0

Please sign in to comment.