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