Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Coroutine::resume(int $cid): bool
Coroutine ID. By default, choose the current coroutine.
Resume the execution of a coroutine by coroutine ID.
<?php
use OpenSwoole\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";