1
0
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:
Aaron Piotrowski 2017-07-28 17:34:24 -05:00
parent a027ef930b
commit 84b611e780
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
10 changed files with 20 additions and 20 deletions

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -1,6 +1,6 @@
<?php
namespace Amp\Parallel\Sync\Internal;
namespace Amp\Parallel\Sync;
use Amp\Parallel\PanicError;

View File

@ -1,6 +1,6 @@
<?php
namespace Amp\Parallel\Sync\Internal;
namespace Amp\Parallel\Sync;
interface ExitResult {
/**

View File

@ -1,6 +1,6 @@
<?php
namespace Amp\Parallel\Sync\Internal;
namespace Amp\Parallel\Sync;
class ExitSuccess implements ExitResult {
/** @var mixed */

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -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 {