1
0
mirror of https://github.com/danog/parallel.git synced 2025-01-22 22:11:11 +01:00

Fix DefaultPool::shutdown()

Forgot to update this to match Worker::shutdown() behavior.
This commit is contained in:
Aaron Piotrowski 2018-10-27 11:16:10 -05:00
parent eff56fb849
commit 4c3c93e46a
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
2 changed files with 9 additions and 10 deletions

View File

@ -35,6 +35,9 @@ final class DefaultPool implements Pool
/** @var \Closure */
private $push;
/** @var \Amp\Promise|null */
private $exitStatus;
/**
* Creates a new worker pool.
*
@ -162,8 +165,8 @@ final class DefaultPool implements Pool
*/
public function shutdown(): Promise
{
if (!$this->isRunning()) {
throw new StatusError("The pool was shutdown");
if ($this->exitStatus) {
return $this->exitStatus;
}
$this->running = false;
@ -175,7 +178,7 @@ final class DefaultPool implements Pool
}
}
return Promise\all($shutdowns);
return $this->exitStatus = Promise\all($shutdowns);
}
/**

View File

@ -42,19 +42,15 @@ abstract class AbstractPoolTest extends TestCase
});
}
/**
* @expectedException \Amp\Parallel\Context\StatusError
* @expectedExceptionMessage The pool was shutdown
*/
public function testShutdownShouldThrowStatusError()
public function testShutdownShouldReturnSameResult()
{
Loop::run(function () {
$pool = $this->createPool();
$this->assertTrue($pool->isIdle());
yield $pool->shutdown();
yield $pool->shutdown();
$result = yield $pool->shutdown();
$this->assertSame($result, yield $pool->shutdown());
});
}