Skip to content

Commit

Permalink
reduced idle CPU usage of Mojo::IOLoop further
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 4, 2013
1 parent 4edccdf commit 03f6d26
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -178,10 +178,11 @@ sub timer {
sub _accepting {
my $self = shift;

# Check connection limit
return if $self->{accepting};
# Check if we have acceptors
my $acceptors = $self->{acceptors} ||= {};
return unless keys %$acceptors;
return $self->_remove(delete $self->{accept}) unless keys %$acceptors;

# Check connection limit
my $i = keys %{$self->{connections}};
my $max = $self->max_connections;
return unless $i < $max;
Expand All @@ -190,7 +191,7 @@ sub _accepting {
if (my $cb = $self->lock) { return unless $self->$cb(!$i) }
$self->_remove(delete $self->{accept});

# Check if multi-accept is desirable and start accepting
# Check if multi-accept is desirable
my $multi = $self->multi_accept;
$_->multi_accept($max < $multi ? 1 : $multi)->start for values %$acceptors;
$self->{accepting}++;
Expand Down

0 comments on commit 03f6d26

Please sign in to comment.