Nexus API Reference

WorkerRunnable extends Runnable
in package

FinalYes
Tags
psalm-api

Thread entrypoint for each worker in the pool.

Swoole\Thread\Pool constructs each Runnable with exactly (Atomic $running, int $index) and then invokes run($args), where $args is the array provided via Pool::withArguments(). All worker dependencies must therefore travel through $args — they cannot be injected via the constructor.

Argument layout (matches WorkerPoolBootstrap::runWithPool()): [0] Map $directory [1] ArrayList $queues — Swoole converts PHP array → ArrayList [2] Atomic $workerIdCounter [3] int $workerCount — scalars used to rebuild WorkerPoolConfig [4] string $systemNamePrefix [5] string $handlerClass [6] string $serializedConfigure [7] string $loggerClass [8] string $serializedLoggerFactory

The parent Runnable defines $running and $id; we inherit its constructor unchanged and do all real work inside run().

IMPORTANT: Do NOT wrap the body in Swoole\Coroutine\run() — $system->run() starts the Swoole event loop itself, and nesting another run() inside a coroutine raises "Unable to call Event::wait() in coroutine".

psalm-suppress

UnusedClass, UndefinedClass, MissingDependency, PropertyNotSetInConstructor

Table of Contents

Methods

run()  : void

Methods

run()

public run(array<int, mixed> $args) : void
Parameters
$args : array<int, mixed>
Tags
psalm-suppress

UnusedParam


        
On this page

Search results