1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-12 09:09:35 +01:00
parallel/lib/Worker/Pool.php
Aaron Piotrowski da84a772cf Port to Amp
2016-08-18 11:04:48 -05:00

57 lines
1.4 KiB
PHP

<?php
namespace Amp\Concurrent\Worker;
/**
* An interface for worker pools.
*/
interface Pool extends Worker {
/**
* @var int The default minimum pool size.
*/
const DEFAULT_MIN_SIZE = 4;
/**
* @var int The default maximum pool size.
*/
const DEFAULT_MAX_SIZE = 32;
/**
* 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.
*
* @return \Amp\Concurrent\Worker\Worker
*
* @throws \Amp\Concurrent\StatusError If the queue is not running.
*/
public function get(): Worker;
/**
* Gets the number of workers currently running in the pool.
*
* @return int The number of workers.
*/
public function getWorkerCount(): int;
/**
* Gets the number of workers that are currently idle.
*
* @return int The number of idle workers.
*/
public function getIdleWorkerCount(): int;
/**
* Gets the minimum number of workers the pool may have idle.
*
* @return int The minimum number of workers.
*/
public function getMinSize(): int;
/**
* Gets the maximum number of workers the pool may spawn to handle concurrent tasks.
*
* @return int The maximum number of workers.
*/
public function getMaxSize(): int;
}