mpyw\Co\Co::race PHP Method

race() public static method

If no yieldables found, AllFailedException is thrown.
public static race ( mixed $value ) : Generator
$value mixed
return Generator Resolved value.
    public static function race($value)
    {
        (yield Co::RETURN_WITH => (yield ControlUtils::anyOrRace($value, ['\\mpyw\\Co\\Internal\\ControlUtils', 'fail'], 'Co::race() failed.')));
        // @codeCoverageIgnoreStart
    }

Usage Example

Exemplo n.º 1
0
 public function testRaceEmpty()
 {
     try {
         Co::wait(Co::race(['A', 'B']));
         $this->assertTrue(false);
     } catch (AllFailedException $e) {
         $this->assertEquals('Co::race() failed.', $e->getMessage());
         $this->assertEquals(['A', 'B'], $e->getReasons());
     }
 }