2016-08-22 06:40:48 +02:00
|
|
|
<?php declare(strict_types = 1);
|
2015-12-12 05:47:46 +01:00
|
|
|
|
2016-08-23 23:47:40 +02:00
|
|
|
namespace Amp\Parallel\Test\Worker;
|
2016-08-18 18:04:48 +02:00
|
|
|
|
2016-08-23 23:47:40 +02:00
|
|
|
use Amp\Parallel\Worker\{ DefaultPool, WorkerFactory, WorkerThread };
|
2015-12-12 05:47:46 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group threading
|
|
|
|
* @requires extension pthreads
|
|
|
|
*/
|
2016-08-19 00:36:58 +02:00
|
|
|
class ThreadPoolTest extends AbstractPoolTest {
|
|
|
|
protected function createPool($min = null, $max = null) {
|
|
|
|
$factory = $this->createMock(WorkerFactory::class);
|
2015-12-12 06:28:44 +01:00
|
|
|
$factory->method('create')->will($this->returnCallback(function () {
|
2016-08-23 01:25:19 +02:00
|
|
|
return new WorkerThread;
|
2015-12-12 06:28:44 +01:00
|
|
|
}));
|
|
|
|
|
|
|
|
return new DefaultPool($min, $max, $factory);
|
2015-12-12 05:47:46 +01:00
|
|
|
}
|
|
|
|
}
|