mirror of
https://github.com/amphp/parallel.git
synced 2025-03-14 23:19:41 +01:00
Thread worker tests
This commit is contained in:
parent
8984c838c2
commit
f013263aff
@ -7,9 +7,6 @@ use Amp\Parallel\Context\Context;
|
||||
use Amp\Parallel\Context\ContextFactory;
|
||||
use Amp\Parallel\Context\ProcessContextFactory;
|
||||
|
||||
/**
|
||||
* @group process
|
||||
*/
|
||||
class ProcessPoolTest extends AbstractPoolTest
|
||||
{
|
||||
public function createContextFactory(): ContextFactory
|
||||
|
26
test/Worker/ThreadPoolTest.php
Normal file
26
test/Worker/ThreadPoolTest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Amp\Parallel\Test\Worker;
|
||||
|
||||
use Amp\Cancellation;
|
||||
use Amp\Parallel\Context\Context;
|
||||
use Amp\Parallel\Context\ContextFactory;
|
||||
use Amp\Parallel\Context\ThreadContext;
|
||||
use Amp\Parallel\Context\ThreadContextFactory;
|
||||
|
||||
class ThreadPoolTest extends AbstractPoolTest
|
||||
{
|
||||
public function createContextFactory(): ContextFactory
|
||||
{
|
||||
if (!ThreadContext::isSupported()) {
|
||||
$this->markTestSkipped('ext-parallel required');
|
||||
}
|
||||
|
||||
return new class implements ContextFactory {
|
||||
public function start(array|string $script, ?Cancellation $cancellation = null): Context
|
||||
{
|
||||
return (new ThreadContextFactory())->start($script, cancellation: $cancellation);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
26
test/Worker/ThreadWorkerTest.php
Normal file
26
test/Worker/ThreadWorkerTest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Amp\Parallel\Test\Worker;
|
||||
|
||||
use Amp\Cancellation;
|
||||
use Amp\Parallel\Context\Context;
|
||||
use Amp\Parallel\Context\ContextFactory;
|
||||
use Amp\Parallel\Context\ThreadContext;
|
||||
use Amp\Parallel\Context\ThreadContextFactory;
|
||||
|
||||
class ThreadWorkerTest extends AbstractWorkerTest
|
||||
{
|
||||
public function createContextFactory(): ContextFactory
|
||||
{
|
||||
if (!ThreadContext::isSupported()) {
|
||||
$this->markTestSkipped('ext-parallel required');
|
||||
}
|
||||
|
||||
return new class implements ContextFactory {
|
||||
public function start(array|string $script, ?Cancellation $cancellation = null): Context
|
||||
{
|
||||
return (new ThreadContextFactory())->start($script, cancellation: $cancellation);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user