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
파일 보기 프로젝트 열기: icicleio/concurrent 1 사용 예제들

공개 메소드들

메소드 설명
__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 ( )