PHP Class 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.
Inheritance: implements Pool
Afficher le fichier Open project: icicleio/concurrent Class Usage Examples

Méthodes publiques

Méthode Description
__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.

Private Methods

Méthode Description
createWorker ( ) : Worker Creates a worker and adds them to the pool.
push ( Worker $worker ) Pushes the worker back into the queue.

Method Details

__construct() public méthode

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() public méthode

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.
Résultat Generator

get() public méthode

public get ( ) : Worker
Résultat Worker

getIdleWorkerCount() public méthode

public getIdleWorkerCount ( ) : integer
Résultat integer

getMaxSize() public méthode

public getMaxSize ( ) : integer
Résultat integer

getMinSize() public méthode

public getMinSize ( ) : integer
Résultat integer

getWorkerCount() public méthode

public getWorkerCount ( ) : integer
Résultat integer

isIdle() public méthode

Checks if the pool has any idle workers.
public isIdle ( ) : boolean
Résultat boolean True if the pool has at least one idle worker, otherwise false.

isRunning() public méthode

Checks if the pool is running.
public isRunning ( ) : boolean
Résultat boolean True if the pool is running, otherwise false.

kill() public méthode

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

shutdown() public méthode

Shuts down the pool and all workers in it.
public shutdown ( ) : Generator
Résultat Generator

start() public méthode

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 ( )