runNonBlocking()

Runs a new coroutine and non-blocks the current thread. This static function should not be used from a coroutine.

CoroutineGen::runNonBlocking(
    function() : \Generator {
        $return = yield file_get_contents('http://www.weather.com.cn/data/cityinfo/101270101.html');
        var_dump($return);
    },
    function() : \Generator {
        yield var_dump("END!");
    },
    function() {
        var_dump("START!");
    },
    function() {
        var_dump("Hello World!");
    }
);

Output:

string(6) "START!"
string(12) "Hello World!"
string(10989) "<!DOCTYPE HTML>
<html>
<head> ...."

string(4) "END!"

Example other:

Output:

Last updated