DelegatingWorkerPool
in package
implements
LimitedWorkerPool
uses
ForbidCloning, ForbidSerialization
Table of Contents
Interfaces
- LimitedWorkerPool
- An interface for worker pools.
Properties
- $limit : int
- $pendingWorkerCount : int
- $pool : WorkerPool
- $waiting : SplQueue<string|int, DeferredFuture<string|int, Worker|null>>
- $workerStorage : array<int, Worker>
Methods
- __construct() : mixed
- __serialize() : never
- __unserialize() : never
- 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>
- __clone() : mixed
- clearWaiting() : void
- push() : void
- selectWorker() : Worker
Properties
$limit read-only
private
int
$limit
$pendingWorkerCount
private
int
$pendingWorkerCount
= 0
$pool read-only
private
WorkerPool
$pool
$waiting read-only
private
SplQueue<string|int, DeferredFuture<string|int, Worker|null>>
$waiting
$workerStorage
private
array<int, Worker>
$workerStorage
= []
Methods
__construct()
public
__construct(WorkerPool $pool, int $limit) : mixed
Parameters
- $pool : WorkerPool
- $limit : int
-
Maximum number of workers to use from the delegate pool.
__serialize()
public
final __serialize() : never
Return values
never__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : never
Parameters
- $data : array<string|int, mixed>
Return values
nevergetIdleWorkerCount()
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().
Return values
WorkergetWorkerCount()
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
boolisRunning()
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 $task[, Cancellation|null $cancellation = null ]) : Execution<TReceive, TSend>
Parameters
- $task : Task
-
The task to execute.
- $cancellation : Cancellation|null = null
-
Token to request cancellation. The task must support cancellation for this to have any effect.
Return values
Execution<TReceive, TSend>__clone()
protected
final __clone() : mixed
clearWaiting()
private
clearWaiting(Throwable $exception) : void
Parameters
- $exception : Throwable
push()
private
push(Worker $worker) : void
Parameters
- $worker : Worker
selectWorker()
private
selectWorker() : Worker