1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-13 09:37:26 +01:00
parallel/lib/Worker/Pool.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2016-12-30 02:16:04 +01:00
<?php
2016-08-18 18:04:48 +02:00
2016-08-23 23:47:40 +02:00
namespace Amp\Parallel\Worker;
/**
2015-12-05 06:50:32 +01:00
* An interface for worker pools.
*/
2018-10-07 16:50:45 +02:00
interface Pool extends Worker
{
2016-08-26 17:10:03 +02:00
/** @var int The default maximum pool size. */
2015-12-16 22:53:53 +01:00
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-23 23:47:40 +02:00
* @return \Amp\Parallel\Worker\Worker
*
2017-12-08 04:26:55 +01:00
* @throws \Amp\Parallel\Context\StatusError If the queue is not running.
*/
public function getWorker(): 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 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;
}