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.
Wait for the given coroutines to finish.
Get the coroutine statistics.
Determine if a coroutine exists.
Get all coroutine IDs.
Details
at line 27
__construct(callable $callable)
Create a new coroutine instance.
at line 35
static CoroutineInterface
create(callable $callable, mixed ...$data)
Create and execute a new coroutine.
at line 45
CoroutineInterface
execute(mixed ...$data)
Execute the coroutine.
at line 63
int
getId()
Get the coroutine ID.
at line 74
static int
id()
Get the current coroutine ID.
at line 82
static int
pid(int|null $id = null)
Get the parent coroutine ID.
at line 104
static void
set(array $config)
Set the coroutine configuration.
Boot-only. Mutates Swoole's process-global coroutine configuration; calling this per-request changes settings for every concurrent coroutine in the worker.
at line 112
static ArrayObject|null
getContextFor(int|null $id = null)
Get the coroutine context.
at line 124
static void
defer(callable $callable)
Register a callback to be executed when the coroutine ends.
at line 132
static bool
yield()
Yield the current coroutine.
at line 140
static bool
resumeById(int $id)
Resume a coroutine by ID.
at line 148
static bool
cancelById(int $id, bool $throwException = false)
Cancel a coroutine by ID.
at line 157
static bool
join(array $coroutineIds, float $timeout = -1)
Wait for the given coroutines to finish.
at line 166
static array
stats()
Get the coroutine statistics.
at line 174
static bool
exists(int $id)
Determine if a coroutine exists.
at line 184
static iterable
list()
Get all coroutine IDs.