PHP Класс Icicle\Concurrent\Worker\DefaultPool

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.
Наследование: implements Pool
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( integer $minSize = null, integer $maxSize = null, Icicle\Concurrent\Worker\WorkerFactory $factory = null ) Creates a new worker pool.
enqueue ( Icicle\Concurrent\Worker\Task $task ) : Generator Enqueues a task to be executed by the worker pool.
get ( ) : Worker
getIdleWorkerCount ( ) : integer
getMaxSize ( ) : integer
getMinSize ( ) : integer
getWorkerCount ( ) : integer
isIdle ( ) : boolean Checks if the pool has any idle workers.
isRunning ( ) : boolean Checks if the pool is running.
kill ( ) Kills all workers in the pool and halts the worker pool.
shutdown ( ) : Generator Shuts down the pool and all workers in it.
start ( ) Starts the worker pool execution.

Приватные методы

Метод Описание
createWorker ( ) : Worker Creates a worker and adds them to the pool.
push ( Worker $worker ) Pushes the worker back into the queue.

Описание методов

__construct() публичный метод

Creates a new worker pool.
public __construct ( integer $minSize = null, integer $maxSize = null, Icicle\Concurrent\Worker\WorkerFactory $factory = null )
$minSize integer The minimum number of workers the pool should spawn. Defaults to `Pool::DEFAULT_MIN_SIZE`.
$maxSize integer The maximum number of workers the pool should spawn. Defaults to `Pool::DEFAULT_MAX_SIZE`.
$factory Icicle\Concurrent\Worker\WorkerFactory A worker factory to be used to create new workers.

enqueue() публичный метод

Enqueues a task to be executed by the worker pool.
public enqueue ( Icicle\Concurrent\Worker\Task $task ) : Generator
$task Icicle\Concurrent\Worker\Task The task to enqueue.
Результат Generator

get() публичный метод

public get ( ) : Worker
Результат Worker

getIdleWorkerCount() публичный метод

public getIdleWorkerCount ( ) : integer
Результат integer

getMaxSize() публичный метод

public getMaxSize ( ) : integer
Результат integer

getMinSize() публичный метод

public getMinSize ( ) : integer
Результат integer

getWorkerCount() публичный метод

public getWorkerCount ( ) : integer
Результат integer

isIdle() публичный метод

Checks if the pool has any idle workers.
public isIdle ( ) : boolean
Результат boolean True if the pool has at least one idle worker, otherwise false.

isRunning() публичный метод

Checks if the pool is running.
public isRunning ( ) : boolean
Результат boolean True if the pool is running, otherwise false.

kill() публичный метод

Kills all workers in the pool and halts the worker pool.
public kill ( )

shutdown() публичный метод

Shuts down the pool and all workers in it.
public shutdown ( ) : Generator
Результат Generator

start() публичный метод

When the worker pool starts up, the minimum number of workers will be created. This adds some overhead to starting the pool, but allows for greater performance during runtime.
public start ( )