1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-11 00:29:46 +01:00
parallel/lib/Worker/Pool.php

57 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2016-08-18 18:04:48 +02:00
namespace Amp\Concurrent\Worker;
/**
2015-12-05 06:50:32 +01:00
* An interface for worker pools.
*/
2016-08-18 18:04:48 +02:00
interface Pool extends Worker {
2015-12-16 22:53:53 +01:00
/**
* @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.
*
2016-08-18 18:04:48 +02:00
* @return \Amp\Concurrent\Worker\Worker
*
2016-08-18 18:04:48 +02:00
* @throws \Amp\Concurrent\StatusError If the queue is not running.
*/
2016-01-23 07:00:56 +01:00
public function get(): Worker;
2015-08-29 03:30:53 +02:00
/**
2015-12-05 06:50:32 +01:00
* Gets the number of workers currently running in the pool.
*
2015-12-05 06:50:32 +01:00
* @return int The number of workers.
*/
2016-01-23 07:00:56 +01:00
public function getWorkerCount(): int;
/**
2015-12-05 06:50:32 +01:00
* Gets the number of workers that are currently idle.
*
2015-12-05 06:50:32 +01:00
* @return int The number of idle workers.
*/
2016-01-23 07:00:56 +01:00
public function getIdleWorkerCount(): int;
2015-12-16 22:53:53 +01:00
/**
* Gets the minimum number of workers the pool may have idle.
*
* @return int The minimum number of workers.
*/
2016-01-23 07:00:56 +01:00
public function getMinSize(): int;
2015-12-16 22:53:53 +01:00
/**
* Gets the maximum number of workers the pool may spawn to handle concurrent tasks.
*
* @return int The maximum number of workers.
*/
2016-01-23 07:00:56 +01:00
public function getMaxSize(): int;
}