Swoole Coroutine Run

Coroutine\Run

Swoole Run is designed to replace the patten go() + Swoole\Event::wait() as a context for executing coroutines outside server.

Coroutine\Run is the alias of Coroutine\Scheduler.

Example:

<?php
$run = new Coroutine\Run;
$run->add(function () {
    Co::sleep(1);
    echo "Done.\n";
});
$run->start();

Depreciation Example:

<?php
go(function () {
    Co::sleep(1);
    echo "Done.\n";
});

Swoole\Event::wait();