OpenSwoole\Coroutine::resume

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

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

Parameters

cid

Coroutine ID. By default, choose the current coroutine.

Return

Description

Resume the execution of a coroutine by coroutine ID.

Example

<?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";
Last updated on September 1, 2022