PHP Class mpyw\Co\Co

Inheritance: implements mpyw\Co\CoInterface
Exibir arquivo Open project: mpyw/co Class Usage Examples

Public Methods

Method Description
all ( mixed $value ) : Generator Wrap value with the Generator that returns the all results.
any ( mixed $value ) : Generator Wrap value with the Generator that returns the first successful result.
async ( mixed $value, mixed $throw = null ) Value is recursively resolved, but we never wait it.
getDefaultOptions ( ) : array Get CoOption default as array.
isRunning ( ) : boolean Return if Co::wait() is running.
race ( mixed $value ) : Generator Wrap value with the Generator that returns the first result.
setDefaultOptions ( array $options ) Overwrite CoOption default.
wait ( mixed $value, array $options = [] ) : mixed Wait until value is recursively resolved to return it.

Private Methods

Method Description
__construct ( ) External instantiation is forbidden.
getRootGenerator ( mixed $throw, mixed $value, &$return ) Return root wrapper generator.
processGeneratorContainer ( GeneratorContainer $gc ) : React\Promise\PromiseInterface Handle resolving generators.
processGeneratorContainerDone ( GeneratorContainer $gc ) : React\Promise\PromiseInterface Handle resolving generators already done.
processGeneratorContainerRunning ( GeneratorContainer $gc ) : React\Promise\PromiseInterface Handle resolving generators still running.
promiseAll ( array $yieldables, boolean $throw_acceptable ) : React\Promise\PromiseInterface Promise all changes in yieldables are prepared.
start ( mixed $value, boolean $wait = true, mixed $throw = null ) Start resovling.

Method Details

all() public static method

Normally you don't have to use this method, just yield an array that contains yieldables. You should use only with Co::race() or Co::any().
public static all ( mixed $value ) : Generator
$value mixed
return Generator Resolved value.

any() public static method

If all yieldables failed, AllFailedException is thrown. If no yieldables found, AllFailedException is thrown.
public static any ( mixed $value ) : Generator
$value mixed
return Generator Resolved value.

async() public static method

This function must be called along with Co::wait().
public static async ( mixed $value, mixed $throw = null )
$value mixed
$throw mixed

getDefaultOptions() public static method

Get CoOption default as array.
public static getDefaultOptions ( ) : array
return array

isRunning() public static method

Return if Co::wait() is running.
public static isRunning ( ) : boolean
return boolean

race() public static method

If no yieldables found, AllFailedException is thrown.
public static race ( mixed $value ) : Generator
$value mixed
return Generator Resolved value.

setDefaultOptions() public static method

Overwrite CoOption default.
public static setDefaultOptions ( array $options )
$options array

wait() public static method

This function call must be atomic.
public static wait ( mixed $value, array $options = [] ) : mixed
$value mixed
$options array
return mixed