Amp\Parallel\Worker\Pool interface Pool extends Amp\Parallel\Worker\Worker

An interface for worker pools.

Summary

Properties

Methods

Methods

get — public function get(): Amp\Parallel\Worker\Worker

Gets a worker from the pool. The worker is marked as busy and will only be reused if the pool runs out of idle workers. The worker will be automatically marked as idle once no references to the returned worker remain.

getWorkerCount — public function getWorkerCount(): int

Gets the number of workers currently running in the pool.

getIdleWorkerCount — public function getIdleWorkerCount(): int

Gets the number of workers that are currently idle.

getMaxSize — public function getMaxSize(): int

Gets the maximum number of workers the pool may spawn to handle concurrent tasks.

isRunning — public function isRunning(): bool

Checks if the worker is running.

isIdle — public function isIdle(): bool

Checks if the worker is currently idle.

enqueue — public function enqueue(Amp\Parallel\Worker\Task $task): Amp\Promise
No documentation.
Type Parameter Description Default Value
Amp\Parallel\Worker\Task $task No documentation. none
shutdown — public function shutdown(): Amp\Promise
No documentation.
kill — public function kill()

Immediately kills the context.