diff --git a/lib/Forking/Fork.php b/lib/Forking/Fork.php index a65fdc8..df78ae8 100644 --- a/lib/Forking/Fork.php +++ b/lib/Forking/Fork.php @@ -13,7 +13,7 @@ use Amp\Parallel\{ SynchronizationError }; use Amp\Parallel\Sync\{ Channel, ChannelledSocket }; -use Amp\Parallel\Sync\Internal\{ ExitFailure, ExitStatus, ExitSuccess }; +use Amp\Parallel\Sync\Internal\{ ExitFailure, ExitResult, ExitSuccess }; use AsyncInterop\{ Loop, Promise }; /** @@ -302,9 +302,9 @@ class Fork implements Process, Strand { try { $response = yield $this->channel->receive(); - if (!$response instanceof ExitStatus) { + if (!$response instanceof ExitResult) { throw new SynchronizationError(\sprintf( - 'Did not receive an exit status from fork. Instead received data of type %s', + 'Did not receive an exit result from fork. Instead received data of type %s', \is_object($response) ? \get_class($response) : \gettype($response) )); } @@ -324,7 +324,7 @@ class Fork implements Process, Strand { } return \Amp\pipe($this->channel->receive(), static function ($data) { - if ($data instanceof ExitStatus) { + if ($data instanceof ExitResult) { $data = $data->getResult(); throw new SynchronizationError(\sprintf( 'Forked process unexpectedly exited with result of type: %s', @@ -345,8 +345,8 @@ class Fork implements Process, Strand { throw new StatusError('The fork has not been started or has already finished.'); } - if ($data instanceof ExitStatus) { - throw new \Error('Cannot send exit status objects.'); + if ($data instanceof ExitResult) { + throw new \Error('Cannot send exit result objects.'); } return $this->channel->send($data); diff --git a/lib/Process/ChannelledProcess.php b/lib/Process/ChannelledProcess.php index 1acb28f..64db65d 100644 --- a/lib/Process/ChannelledProcess.php +++ b/lib/Process/ChannelledProcess.php @@ -4,7 +4,7 @@ namespace Amp\Parallel\Process; use Amp\Coroutine; use Amp\Parallel\{ ContextException, Process as ProcessContext, StatusError, Strand, SynchronizationError }; -use Amp\Parallel\Sync\{ ChannelledSocket, Internal\ExitStatus }; +use Amp\Parallel\Sync\{ ChannelledSocket, Internal\ExitResult }; use Amp\Process\Process; use AsyncInterop\Promise; @@ -60,7 +60,7 @@ class ChannelledProcess implements ProcessContext, Strand { } return \Amp\pipe($this->channel->receive(), static function ($data) { - if ($data instanceof ExitStatus) { + if ($data instanceof ExitResult) { $data = $data->getResult(); throw new SynchronizationError(\sprintf( "Process unexpectedly exited with result of type: %s", @@ -80,8 +80,8 @@ class ChannelledProcess implements ProcessContext, Strand { throw new StatusError("The process has not been started"); } - if ($data instanceof ExitStatus) { - throw new \Error("Cannot send exit status objects"); + if ($data instanceof ExitResult) { + throw new \Error("Cannot send exit result objects"); } return $this->channel->send($data); @@ -101,8 +101,8 @@ class ChannelledProcess implements ProcessContext, Strand { private function doJoin(): \Generator { try { $data = yield $this->channel->receive(); - if (!$data instanceof ExitStatus) { - throw new SynchronizationError("Did not receive an exit status from process"); + if (!$data instanceof ExitResult) { + throw new SynchronizationError("Did not receive an exit result from process"); } } catch (\Throwable $exception) { $this->kill(); diff --git a/lib/Sync/Channel.php b/lib/Sync/Channel.php index 7796db1..ad49265 100644 --- a/lib/Sync/Channel.php +++ b/lib/Sync/Channel.php @@ -28,7 +28,7 @@ interface Channel { * @throws \Amp\Parallel\SynchronizationError If the context has not been started or the context * unexpectedly ends. * @throws \Amp\Parallel\ChannelException If sending on the channel fails. - * @throws \Error If an ExitStatus object is given. + * @throws \Error If an ExitResult object is given. * @throws \Amp\Parallel\SerializationException If serializing the data fails. */ public function send($data): Promise; diff --git a/lib/Sync/Internal/ExitFailure.php b/lib/Sync/Internal/ExitFailure.php index 0ac1692..1854c9d 100644 --- a/lib/Sync/Internal/ExitFailure.php +++ b/lib/Sync/Internal/ExitFailure.php @@ -4,7 +4,7 @@ namespace Amp\Parallel\Sync\Internal; use Amp\Parallel\PanicError; -class ExitFailure implements ExitStatus { +class ExitFailure implements ExitResult { /** @var string */ private $type; diff --git a/lib/Sync/Internal/ExitStatus.php b/lib/Sync/Internal/ExitResult.php similarity index 92% rename from lib/Sync/Internal/ExitStatus.php rename to lib/Sync/Internal/ExitResult.php index 9f66827..ff8de80 100644 --- a/lib/Sync/Internal/ExitStatus.php +++ b/lib/Sync/Internal/ExitResult.php @@ -2,7 +2,7 @@ namespace Amp\Parallel\Sync\Internal; -interface ExitStatus { +interface ExitResult { /** * @return mixed Return value of the callable given to the execution context. * diff --git a/lib/Sync/Internal/ExitSuccess.php b/lib/Sync/Internal/ExitSuccess.php index efed9f6..1f53d67 100644 --- a/lib/Sync/Internal/ExitSuccess.php +++ b/lib/Sync/Internal/ExitSuccess.php @@ -2,7 +2,7 @@ namespace Amp\Parallel\Sync\Internal; -class ExitSuccess implements ExitStatus { +class ExitSuccess implements ExitResult { /** @var mixed */ private $result; diff --git a/lib/Threading/Thread.php b/lib/Threading/Thread.php index d466b4a..524981d 100644 --- a/lib/Threading/Thread.php +++ b/lib/Threading/Thread.php @@ -4,7 +4,7 @@ namespace Amp\Parallel\Threading; use Amp\Coroutine; use Amp\Parallel\{ ContextException, StatusError, SynchronizationError, Strand }; -use Amp\Parallel\Sync\{ ChannelledSocket, Internal\ExitStatus }; +use Amp\Parallel\Sync\{ ChannelledSocket, Internal\ExitResult }; use AsyncInterop\Promise; /** @@ -201,8 +201,8 @@ class Thread implements Strand { try { $response = yield $this->channel->receive(); - if (!$response instanceof ExitStatus) { - throw new SynchronizationError('Did not receive an exit status from thread.'); + if (!$response instanceof ExitResult) { + throw new SynchronizationError('Did not receive an exit result from thread.'); } } catch (\Throwable $exception) { $this->kill(); @@ -223,7 +223,7 @@ class Thread implements Strand { } return \Amp\pipe($this->channel->receive(), static function ($data) { - if ($data instanceof ExitStatus) { + if ($data instanceof ExitResult) { $data = $data->getResult(); throw new SynchronizationError(\sprintf( 'Thread unexpectedly exited with result of type: %s', @@ -243,8 +243,8 @@ class Thread implements Strand { throw new StatusError('The thread has not been started or has already finished.'); } - if ($data instanceof ExitStatus) { - throw new \Error('Cannot send exit status objects.'); + if ($data instanceof ExitResult) { + throw new \Error('Cannot send exit result objects.'); } return $this->channel->send($data); diff --git a/test/AbstractContextTest.php b/test/AbstractContextTest.php index 895e627..ec85b8f 100644 --- a/test/AbstractContextTest.php +++ b/test/AbstractContextTest.php @@ -225,7 +225,7 @@ abstract class AbstractContextTest extends TestCase { * @depends testSendAndReceive * @expectedException \Error */ - public function testSendExitStatus() { + public function testSendExitResult() { Loop::execute(\Amp\wrap(function () { $context = $this->createContext(function () { $value = yield $this->receive();