Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
Latest version:
pecl install openswoole-22.1.2
<?php Swoole\Coroutine::resume(int $cid): bool
Coroutine ID. By default, choose the current coroutine.
Resume the execution of a coroutine by coroutine ID.
<?php
use Swoole\Coroutine as co;
$id = go(function(){
$id = co::getCid();
echo "start coro $id\n";
co::yeild();
echo "resume coro $id @1\n";
co::yeild();
echo "resume coro $id @2\n";
});
echo "start to resume $id @1\n";
co::resume($id);
echo "start to resume $id @2\n";
co::resume($id);
echo "main\n";