public function shutdown() : \Generator
{
if (!$this->isRunning()) {
throw new StatusError('The pool is not running.');
}
$this->running = false;
$shutdowns = [];
foreach ($this->workers as $worker) {
if ($worker->isRunning()) {
$shutdowns[] = new Coroutine($worker->shutdown());
}
}
return (yield Awaitable\reduce($shutdowns, function ($carry, $value) {
return $carry ?: $value;
}, 0));
}