Coroutine
class Coroutine implements CoroutineInterface
Methods
Create a new coroutine instance.
Create and execute a new coroutine.
Execute the coroutine.
Get the coroutine ID.
Get the current coroutine ID.
Get the parent coroutine ID.
Set the coroutine configuration.
Get the coroutine context.
Register a callback to be executed when the coroutine ends.
Yield the current coroutine.
Resume a coroutine by ID.
Cancel a coroutine by ID.
Determine if the current coroutine was canceled.
Wait for the given coroutines to finish.
Get the coroutine statistics.
Determine if a coroutine exists.
Get all coroutine IDs.
Details
at line 28
__construct(callable $callable)
Create a new coroutine instance.
at line 36
static CoroutineInterface
create(callable $callable, mixed ...$data)
Create and execute a new coroutine.
at line 47
CoroutineInterface
execute(mixed ...$data)
Execute the coroutine.
at line 66
int
getId()
Get the coroutine ID.
at line 77
static int
id()
Get the current coroutine ID.
at line 85
static int
pid(int|null $id = null)
Get the parent coroutine ID.
at line 107
static void
set(array $config)
Set the coroutine configuration.
Mutates Swoole's process-global coroutine configuration; calling this per-request changes settings for every concurrent coroutine in the worker.
at line 116
static ArrayObject|null
getContextFor(int|null $id = null)
Get the coroutine context.
at line 128
static void
defer(callable $callable)
Register a callback to be executed when the coroutine ends.
at line 136
static bool
yield()
Yield the current coroutine.
at line 144
static bool
resumeById(int $id)
Resume a coroutine by ID.
at line 152
static bool
cancelById(int $id, bool $throwException = false)
Cancel a coroutine by ID.
at line 164
static bool
isCanceled()
Determine if the current coroutine was canceled.
This state must be inspected at the cancellation boundary. It returns false outside a coroutine.
at line 176
static bool
join(array $coroutineIds, float $timeout = -1)
Wait for the given coroutines to finish.
at line 185
static array
stats()
Get the coroutine statistics.
at line 193
static bool
exists(int $id)
Determine if a coroutine exists.
at line 203
static iterable
list()
Get all coroutine IDs.