Provides a pool of workers that can be used to execute multiple tasks asynchronously.
A worker pool is a collection of worker threads that can perform multiple tasks simultaneously. The load on each worker is balanced such that tasks are completed as soon as possible and workers are used efficiently.
Creates a new worker pool.
|int||$maxSize||The maximum number of workers the pool should spawn. Defaults to `Pool::DEFAULT_MAX_SIZE`.||self::DEFAULT_MAX_SIZE|
|Amp\Parallel\Worker\WorkerFactory|null||$factory||A worker factory to be used to create new workers.||null|
Checks if the pool is running.
Checks if the pool has any idle workers.
Gets the maximum number of workers the pool may spawn to handle concurrent tasks.
Gets the number of workers currently running in the pool.
Gets the number of workers that are currently idle.
Kills all workers in the pool and halts the worker pool.
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.
Pulls a worker from the pool. The worker should be put back into the pool with push() to be marked as idle.
Pushes the worker back into the pool and mark it as idle.