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:
parent
eff56fb849
commit
4c3c93e46a
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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());
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user