1
0
mirror of https://github.com/danog/parallel.git synced 2025-01-22 14:01:14 +01:00

Update for process changes

This commit is contained in:
Aaron Piotrowski 2017-06-15 23:46:15 -05:00
parent f9be01adb5
commit 820b6897ed
3 changed files with 19 additions and 18 deletions

View File

@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php declare(strict_types = 1);
<?php
use Amp\Parallel\Sync\{ ChannelledSocket, Internal\ExitFailure, Internal\ExitSuccess };
use Amp\Parallel\Worker\{ BasicEnvironment, Internal\TaskRunner };
use Amp\Parallel\Sync;
use Amp\Parallel\Worker;
@cli_set_process_title('amp-worker');
@ -35,14 +35,16 @@ ob_start(function ($data) {
})();
Amp\Loop::run(function () {
$channel = new ChannelledSocket(STDIN, STDOUT, false);
$environment = new BasicEnvironment;
$runner = new TaskRunner($channel, $environment);
$channel = new Sync\ChannelledSocket(STDIN, STDOUT);
$environment = new Worker\BasicEnvironment;
$runner = new Worker\Internal\TaskRunner($channel, $environment);
try {
$result = new ExitSuccess(yield $runner->run());
$result = new Sync\Internal\ExitSuccess(yield $runner->run());
} catch (Sync\ChannelException $exception) {
return; // Parent context died, simply exit.
} catch (Throwable $exception) {
$result = new ExitFailure($exception);
$result = new Sync\Internal\ExitFailure($exception);
}
$channel->send($result); // Do not yield sending result on channel, process does not care if result arrives.

View File

@ -21,17 +21,16 @@
}
],
"require": {
"amphp/amp": "^2.0",
"amphp/byte-stream": "dev-master as 0.1",
"amphp/parser": "^1.0",
"amphp/process": "dev-amp_v2 as 0.2"
"amphp/amp": "^2",
"amphp/byte-stream": "^1",
"amphp/parser": "^1",
"amphp/process": "v0.2.x-dev"
},
"require-dev": {
"amphp/phpunit-util": "dev-master",
"friendsofphp/php-cs-fixer": "^2.3",
"phpunit/phpunit": "^6"
"phpunit/phpunit": "^6",
"amphp/phpunit-util": "^1",
"friendsofphp/php-cs-fixer": "^2.3"
},
"minimum-stability": "dev",
"suggest": {
"ext-pcntl": "Required for fork contexts",
"ext-pthreads": "Required for thread contexts",

View File

@ -8,7 +8,7 @@ use Amp\Parallel\Process as ProcessContext;
use Amp\Parallel\StatusError;
use Amp\Parallel\Strand;
use Amp\Parallel\Sync\ChannelException;
use Amp\Parallel\Sync\ChannelledSocket;
use Amp\Parallel\Sync\ChannelledStream;
use Amp\Parallel\Sync\Internal\ExitResult;
use Amp\Parallel\SynchronizationError;
use Amp\Process\Process;
@ -45,7 +45,7 @@ class ChannelledProcess implements ProcessContext, Strand {
*/
public function start() {
$this->process->start();
$this->channel = new ChannelledSocket($this->process->getStdOut(), $this->process->getStdIn(), false);
$this->channel = new ChannelledStream($this->process->getStdOut(), $this->process->getStdIn());
}
/**