Swoole\Coroutine::resume(int $cid)

Declaration

<?php
Swoole\Coroutine::resume(int $cid)

Parameters

cid

Coroutine ID. By default, choose the current coroutine.

Return

Description

Resume the execution of a coroutine by coroutine ID.

Example

<?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";