1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-26 20:34:40 +01:00

Use null as defaults

This commit is contained in:
Aaron Piotrowski 2015-12-16 16:39:25 -06:00
parent 767b62077b
commit cbc5e4e75e
9 changed files with 17 additions and 13 deletions

View File

@ -55,14 +55,16 @@ class DefaultPool implements Pool
/**
* Creates a new worker pool.
*
* @param int $minSize The minimum number of workers the pool should spawn. Defaults to `Pool::DEFAULT_MIN_SIZE`.
* @param int $maxSize The maximum number of workers the pool should spawn. Defaults to `Pool::DEFAULT_MAX_SIZE`.
* @param int|null $minSize The minimum number of workers the pool should spawn.
* Defaults to `Pool::DEFAULT_MIN_SIZE`.
* @param int|null $maxSize The maximum number of workers the pool should spawn.
* Defaults to `Pool::DEFAULT_MAX_SIZE`.
* @param \Icicle\Concurrent\Worker\WorkerFactory|null $factory A worker factory to be used to create
* new workers.
*
* @throws \Icicle\Exception\InvalidArgumentError
*/
public function __construct($minSize = 0, $maxSize = 0, WorkerFactory $factory = null)
public function __construct($minSize = null, $maxSize = null, WorkerFactory $factory = null)
{
$minSize = $minSize ?: self::DEFAULT_MIN_SIZE;
$maxSize = $maxSize ?: self::DEFAULT_MAX_SIZE;

View File

@ -39,13 +39,15 @@ class DefaultQueue implements Queue
private $running = false;
/**
* @param int $minSize
* @param int $maxSize
* @param int|null $minSize The minimum number of workers the queue should spawn.
* Defaults to `Queue::DEFAULT_MIN_SIZE`.
* @param int|null $maxSize The maximum number of workers the queue should spawn.
* Defaults to `Queue::DEFAULT_MAX_SIZE`.
* @param \Icicle\Concurrent\Worker\WorkerFactory|null $factory Factory used to create new workers.
*
* @throws \Icicle\Exception\InvalidArgumentError If the min or max size are invalid.
*/
public function __construct($minSize = 0, $maxSize = 0, WorkerFactory $factory = null)
public function __construct($minSize = null, $maxSize = null, WorkerFactory $factory = null)
{
$minSize = $minSize ?: self::DEFAULT_MIN_SIZE;
$maxSize = $maxSize ?: self::DEFAULT_MAX_SIZE;

View File

@ -14,7 +14,7 @@ abstract class AbstractPoolTest extends TestCase
*
* @return \Icicle\Concurrent\Worker\Pool
*/
abstract protected function createPool($min = 0, $max = 0);
abstract protected function createPool($min = null, $max = null);
public function testIsRunning()
{

View File

@ -15,7 +15,7 @@ abstract class AbstractQueueTest extends TestCase
*
* @return \Icicle\Concurrent\Worker\Queue
*/
abstract protected function createQueue($min = 0, $max = 0);
abstract protected function createQueue($min = null, $max = null);
public function testIsRunning()
{

View File

@ -11,7 +11,7 @@ use Icicle\Concurrent\Worker\WorkerFork;
*/
class ForkPoolTest extends AbstractPoolTest
{
protected function createPool($min = 0, $max = 0)
protected function createPool($min = null, $max = null)
{
$factory = $this->getMock(WorkerFactory::class);
$factory->method('create')->will($this->returnCallback(function () {

View File

@ -11,7 +11,7 @@ use Icicle\Concurrent\Worker\WorkerFork;
*/
class ForkQueueTest extends AbstractQueueTest
{
protected function createQueue($min = 0, $max = 0)
protected function createQueue($min = null, $max = null)
{
$factory = $this->getMock(WorkerFactory::class);
$factory->method('create')->will($this->returnCallback(function () {

View File

@ -10,7 +10,7 @@ use Icicle\Concurrent\Worker\WorkerProcess;
*/
class ProcessPoolTest extends AbstractPoolTest
{
protected function createPool($min = 0, $max = 0)
protected function createPool($min = null, $max = null)
{
$factory = $this->getMock(WorkerFactory::class);
$factory->method('create')->will($this->returnCallback(function () {

View File

@ -11,7 +11,7 @@ use Icicle\Concurrent\Worker\WorkerThread;
*/
class ThreadPoolTest extends AbstractPoolTest
{
protected function createPool($min = 0, $max = 0)
protected function createPool($min = null, $max = null)
{
$factory = $this->getMock(WorkerFactory::class);
$factory->method('create')->will($this->returnCallback(function () {

View File

@ -11,7 +11,7 @@ use Icicle\Concurrent\Worker\WorkerThread;
*/
class ThreadQueueTest extends AbstractQueueTest
{
protected function createQueue($min = 0, $max = 0)
protected function createQueue($min = null, $max = null)
{
$factory = $this->getMock(WorkerFactory::class);
$factory->method('create')->will($this->returnCallback(function () {