public static function anyOrRace($value, callable $filter, $message)
{
$value = YieldableUtils::normalize($value);
$yieldables = YieldableUtils::getYieldables($value);
$wrapper = self::getWrapperGenerator($yieldables, $filter);
try {
$results = (yield $wrapper);
} catch (ControlException $e) {
(yield CoInterface::RETURN_WITH => $e->getValue());
}
$apply = YieldableUtils::getApplier($value, $yieldables);
throw new AllFailedException($message, 0, $apply($results));
}
/** * Wrap value with the Generator that returns the first result. * If no yieldables found, AllFailedException is thrown. * * @param mixed $value * @return \Generator Resolved value. * @throws \RuntimeException|AllFailedException */ public static function race($value) { (yield Co::RETURN_WITH => (yield ControlUtils::anyOrRace($value, ['\\mpyw\\Co\\Internal\\ControlUtils', 'fail'], 'Co::race() failed.'))); // @codeCoverageIgnoreStart }