Documentation

LimitedWorkerPool extends WorkerPool
in

An interface for worker pools.

Table of Contents

Constants

DEFAULT_WORKER_LIMIT  = 32

Methods

getIdleWorkerCount()  : int
Gets the number of workers that are currently idle.
getWorker()  : 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()  : int
Gets the number of workers currently running in the pool.
getWorkerLimit()  : int
Gets the maximum number of workers the pool may spawn to handle concurrent tasks.
isIdle()  : bool
Checks if the worker is currently idle.
isRunning()  : bool
Checks if the worker is running.
kill()  : void
Immediately kills the context.
shutdown()  : void
Gracefully shutdown the worker once all outstanding tasks have completed executing. Returns once the worker has been shutdown.
submit()  : Execution<TReceive, TSend>

Constants

DEFAULT_WORKER_LIMIT

public int DEFAULT_WORKER_LIMIT = 32

The default maximum pool size.

Methods

getIdleWorkerCount()

Gets the number of workers that are currently idle.

public getIdleWorkerCount() : int
Return values
int

The number of idle workers.

getWorker()

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.

public getWorker() : Worker

This method does not guarantee the worker will be dedicated to a particular task, rather is designed if you wish to send a series of tasks to a single worker. For a dedicated worker, create a new worker using a WorkerFactory or createWorker().

Tags
throws
StatusError

If the pool is not running.

Return values
Worker

getWorkerCount()

Gets the number of workers currently running in the pool.

public getWorkerCount() : int
Return values
int

The number of workers.

getWorkerLimit()

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

public getWorkerLimit() : int
Return values
int

The maximum number of workers.

isIdle()

Checks if the worker is currently idle.

public isIdle() : bool
Return values
bool

isRunning()

Checks if the worker is running.

public isRunning() : bool
Return values
bool

True if the worker is running, otherwise false.

kill()

Immediately kills the context.

public kill() : void

shutdown()

Gracefully shutdown the worker once all outstanding tasks have completed executing. Returns once the worker has been shutdown.

public shutdown() : void

submit()

public submit(Task<TReceive, TSend$task[, Cancellation|null $cancellation = null ]) : Execution<TReceive, TSend>
Parameters
$task : Task<TReceive, TSend>

The task to execute.

$cancellation : Cancellation|null = null

Token to request cancellation. The task must support cancellation for this to have any effect.

Tags
template
template
template

Executes a Task on the worker.

Return values
Execution<TReceive, TSend>

        
On this page

Search results