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

Move GC test to ProcessPoolTest

This commit is contained in:
Aaron Piotrowski 2017-12-27 12:17:35 -06:00
parent 0a474e18c0
commit e6a5de671a
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
2 changed files with 26 additions and 20 deletions

View File

@ -130,24 +130,4 @@ abstract class AbstractPoolTest extends TestCase {
yield $pool->shutdown();
});
}
public function testCleanGarbageCollection() {
// See https://github.com/amphp/parallel-functions/issues/5
Loop::run(function () {
for ($i = 0; $i < 15; $i++) {
$pool = $this->createPool(32);
$values = \range(1, 50);
$tasks = \array_map(function (int $value): Task {
return new TestTask($value);
}, $values);
$promises = \array_map(function (Task $task) use ($pool): Promise {
return $pool->enqueue($task);
}, $tasks);
$this->assertSame($values, yield $promises);
}
});
}
}

View File

@ -2,10 +2,13 @@
namespace Amp\Parallel\Test\Worker;
use Amp\Loop;
use Amp\Parallel\Worker\DefaultPool;
use Amp\Parallel\Worker\Pool;
use Amp\Parallel\Worker\Task;
use Amp\Parallel\Worker\WorkerFactory;
use Amp\Parallel\Worker\WorkerProcess;
use Amp\Promise;
/**
* @group process
@ -19,4 +22,27 @@ class ProcessPoolTest extends AbstractPoolTest {
return new DefaultPool($max, $factory);
}
/**
* @FIXME This test should be moved to AbstractPoolTest once the GC issues with pthreads are resolved.
*/
public function testCleanGarbageCollection() {
// See https://github.com/amphp/parallel-functions/issues/5
Loop::run(function () {
for ($i = 0; $i < 15; $i++) {
$pool = $this->createPool(32);
$values = \range(1, 50);
$tasks = \array_map(function (int $value): Task {
return new TestTask($value);
}, $values);
$promises = \array_map(function (Task $task) use ($pool): Promise {
return $pool->enqueue($task);
}, $tasks);
$this->assertSame($values, yield $promises);
}
});
}
}