mirror of
https://github.com/danog/parallel.git
synced 2024-11-30 04:39:01 +01:00
Move ExitResult classes out of Internal namespace
This commit is contained in:
parent
a027ef930b
commit
84b611e780
@ -70,11 +70,11 @@ Amp\Loop::run(function () {
|
||||
|
||||
$runner = new Worker\TaskRunner($channel, $environment);
|
||||
|
||||
$result = new Sync\Internal\ExitSuccess(yield $runner->run());
|
||||
$result = new Sync\ExitSuccess(yield $runner->run());
|
||||
} catch (Sync\ChannelException $exception) {
|
||||
exit(1); // Parent context died, simply exit.
|
||||
} catch (Throwable $exception) {
|
||||
$result = new Sync\Internal\ExitFailure($exception);
|
||||
$result = new Sync\ExitFailure($exception);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -11,9 +11,9 @@ use Amp\Parallel\Strand;
|
||||
use Amp\Parallel\Sync\Channel;
|
||||
use Amp\Parallel\Sync\ChannelException;
|
||||
use Amp\Parallel\Sync\ChannelledSocket;
|
||||
use Amp\Parallel\Sync\Internal\ExitFailure;
|
||||
use Amp\Parallel\Sync\Internal\ExitResult;
|
||||
use Amp\Parallel\Sync\Internal\ExitSuccess;
|
||||
use Amp\Parallel\Sync\ExitFailure;
|
||||
use Amp\Parallel\Sync\ExitResult;
|
||||
use Amp\Parallel\Sync\ExitSuccess;
|
||||
use Amp\Parallel\Sync\SerializationException;
|
||||
use Amp\Parallel\SynchronizationError;
|
||||
use Amp\Promise;
|
||||
|
@ -10,7 +10,7 @@ use Amp\Parallel\StatusError;
|
||||
use Amp\Parallel\Strand;
|
||||
use Amp\Parallel\Sync\ChannelException;
|
||||
use Amp\Parallel\Sync\ChannelledStream;
|
||||
use Amp\Parallel\Sync\Internal\ExitResult;
|
||||
use Amp\Parallel\Sync\ExitResult;
|
||||
use Amp\Parallel\SynchronizationError;
|
||||
use Amp\Process\Process;
|
||||
use Amp\Promise;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Sync\Internal;
|
||||
namespace Amp\Parallel\Sync;
|
||||
|
||||
use Amp\Parallel\PanicError;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Sync\Internal;
|
||||
namespace Amp\Parallel\Sync;
|
||||
|
||||
interface ExitResult {
|
||||
/**
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Sync\Internal;
|
||||
namespace Amp\Parallel\Sync;
|
||||
|
||||
class ExitSuccess implements ExitResult {
|
||||
/** @var mixed */
|
@ -6,8 +6,8 @@ use Amp\Loop;
|
||||
use Amp\Parallel\Sync\Channel;
|
||||
use Amp\Parallel\Sync\ChannelException;
|
||||
use Amp\Parallel\Sync\ChannelledSocket;
|
||||
use Amp\Parallel\Sync\Internal\ExitFailure;
|
||||
use Amp\Parallel\Sync\Internal\ExitSuccess;
|
||||
use Amp\Parallel\Sync\ExitFailure;
|
||||
use Amp\Parallel\Sync\ExitSuccess;
|
||||
use Amp\Parallel\Sync\SerializationException;
|
||||
use function Amp\call;
|
||||
|
||||
|
@ -9,7 +9,7 @@ use Amp\Parallel\StatusError;
|
||||
use Amp\Parallel\Strand;
|
||||
use Amp\Parallel\Sync\ChannelException;
|
||||
use Amp\Parallel\Sync\ChannelledSocket;
|
||||
use Amp\Parallel\Sync\Internal\ExitResult;
|
||||
use Amp\Parallel\Sync\ExitResult;
|
||||
use Amp\Parallel\SynchronizationError;
|
||||
use Amp\Promise;
|
||||
use function Amp\call;
|
||||
|
@ -111,14 +111,10 @@ abstract class AbstractWorker implements Worker {
|
||||
private function doEnqueue(Task $task): \Generator {
|
||||
$empty = empty($this->jobQueue);
|
||||
|
||||
$job = new Internal\Job($task);
|
||||
$this->jobQueue[$job->getId()] = $deferred = new Deferred;
|
||||
|
||||
try {
|
||||
$job = new Internal\Job($task);
|
||||
$this->jobQueue[$job->getId()] = $deferred = new Deferred;
|
||||
|
||||
if ($empty) {
|
||||
$this->context->receive()->onResolve($this->onResolve);
|
||||
}
|
||||
|
||||
yield $this->context->send($job);
|
||||
} catch (\Throwable $exception) {
|
||||
$exception = new WorkerException("Sending the task to the worker failed", $exception);
|
||||
@ -126,6 +122,10 @@ abstract class AbstractWorker implements Worker {
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
if ($empty) {
|
||||
$this->context->receive()->onResolve($this->onResolve);
|
||||
}
|
||||
|
||||
return yield $deferred->promise();
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace Amp\Parallel\Test;
|
||||
|
||||
use Amp\Loop;
|
||||
use Amp\Parallel\Sync\Internal\ExitSuccess;
|
||||
use Amp\Parallel\Sync\ExitSuccess;
|
||||
use Amp\PHPUnit\TestCase;
|
||||
|
||||
abstract class AbstractContextTest extends TestCase {
|
||||
|
Loading…
Reference in New Issue
Block a user