Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
white-poto committed Nov 23, 2015
1 parent bd10e4e commit c7dba87
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/AbstractPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ public function aliveCount()
return $count;
}

/**
* if all processes are stopped
*
* @return bool
*/
public function isFinished()
{
foreach ($this->processes as $process) {
if (!$process->isStopped()) {
return false;
}
}
return true;
}

/**
* waiting for the sub processes to exit
*
Expand Down
3 changes: 3 additions & 0 deletions src/FixedPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function execute(Process $process)
public function wait($block = false, $interval = 100)
{
do {
if ($this->isFinished()) {
return;
}
parent::wait(false);
if ($this->aliveCount() < $this->max) {
foreach ($this->processes as $process) {
Expand Down

0 comments on commit c7dba87

Please sign in to comment.