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 */
|
/** @var \Closure */
|
||||||
private $push;
|
private $push;
|
||||||
|
|
||||||
|
/** @var \Amp\Promise|null */
|
||||||
|
private $exitStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new worker pool.
|
* Creates a new worker pool.
|
||||||
*
|
*
|
||||||
@ -162,8 +165,8 @@ final class DefaultPool implements Pool
|
|||||||
*/
|
*/
|
||||||
public function shutdown(): Promise
|
public function shutdown(): Promise
|
||||||
{
|
{
|
||||||
if (!$this->isRunning()) {
|
if ($this->exitStatus) {
|
||||||
throw new StatusError("The pool was shutdown");
|
return $this->exitStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->running = false;
|
$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
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testShutdownShouldReturnSameResult()
|
||||||
* @expectedException \Amp\Parallel\Context\StatusError
|
|
||||||
* @expectedExceptionMessage The pool was shutdown
|
|
||||||
*/
|
|
||||||
public function testShutdownShouldThrowStatusError()
|
|
||||||
{
|
{
|
||||||
Loop::run(function () {
|
Loop::run(function () {
|
||||||
$pool = $this->createPool();
|
$pool = $this->createPool();
|
||||||
|
|
||||||
$this->assertTrue($pool->isIdle());
|
$this->assertTrue($pool->isIdle());
|
||||||
|
|
||||||
yield $pool->shutdown();
|
$result = yield $pool->shutdown();
|
||||||
yield $pool->shutdown();
|
$this->assertSame($result, yield $pool->shutdown());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user