public function receive() : \Generator
{
if (null === $this->channel) {
throw new StatusError('The fork has not been started or has already finished.');
}
$data = (yield from $this->channel->receive());
if ($data instanceof ExitStatus) {
$data = $data->getResult();
throw new SynchronizationError(sprintf('Fork unexpectedly exited with result of type: %s', is_object($data) ? get_class($data) : gettype($data)));
}
return $data;
}