1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-04 18:47:50 +01:00
parallel/tests/Worker/PoolTest.php
Aaron Piotrowski 7def2ae5a3 No longer call kill() in destructors
This means forks/processes/threads must be properly shutdown or killed before a reference is lost or the thread will continue to run indefinitely. This was necessary because forks were automatically killing other processes or threads due to calling kill() in the destructor.
2015-09-14 18:59:33 -05:00

31 lines
654 B
PHP

<?php
namespace Icicle\Tests\Concurrent\Worker;
use Icicle\Concurrent\Worker\Pool;
use Icicle\Coroutine;
use Icicle\Loop;
use Icicle\Tests\Concurrent\TestCase;
class PoolTest extends TestCase
{
public function createPool($min = 8, $max = 32)
{
return new Pool($min, $max);
}
public function testEnqueue()
{
Coroutine\create(function () {
$pool = $this->createPool();
$pool->start();
$returnValue = (yield $pool->enqueue(new TestTask(42)));
$this->assertEquals(42, $returnValue);
yield $pool->shutdown();
})->done();
Loop\run();
}
}