From 31cbd9f1977c39bd969e223b81e4ad5ea3db350f Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Wed, 24 Oct 2018 22:31:47 -0500 Subject: [PATCH] Update examples --- examples/process.php | 2 +- examples/shared-memory-parcel.php | 2 +- examples/worker-pool.php | 15 +++++---------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/examples/process.php b/examples/process.php index bca2536..71ea7dc 100755 --- a/examples/process.php +++ b/examples/process.php @@ -21,7 +21,7 @@ Loop::run(function () { \assert($context instanceof Process); // Pipe any data written to the STDOUT in the child process to STDOUT of this process. - Amp\Promise\rethrow(ByteStream\pipe($context->getStdout(), new ByteStream\ResourceOutputStream(STDOUT))); + Amp\Promise\rethrow(ByteStream\pipe($context->getStdout(), ByteStream\getStdout())); print "Waiting 2 seconds to send start data...\n"; yield new Delayed(2000); diff --git a/examples/shared-memory-parcel.php b/examples/shared-memory-parcel.php index 96e7bc4..6dbcd1a 100755 --- a/examples/shared-memory-parcel.php +++ b/examples/shared-memory-parcel.php @@ -20,7 +20,7 @@ Loop::run(function () { \assert($context instanceof Process); // Pipe any data written to the STDOUT in the child process to STDOUT of this process. - Amp\Promise\rethrow(ByteStream\pipe($context->getStdout(), new ByteStream\ResourceOutputStream(STDOUT))); + Amp\Promise\rethrow(ByteStream\pipe($context->getStdout(), ByteStream\getStdout())); yield new Delayed(100); // Give the process time to start and access the parcel. diff --git a/examples/worker-pool.php b/examples/worker-pool.php index 5f8a9aa..71bc9f1 100755 --- a/examples/worker-pool.php +++ b/examples/worker-pool.php @@ -2,7 +2,6 @@ enqueue($task); $url = $task->getArgs()[0]; \printf("\nRead from %s: %d bytes\n", $url, \strlen($result)); - $results[$url] = $result; - }; + return $result; + }); } - $coroutines = \array_map(function (callable $coroutine): Coroutine { - return new Coroutine($coroutine()); - }, $coroutines); - - yield Amp\Promise\all($coroutines); + $results = yield Amp\Promise\all($coroutines); return yield $pool->shutdown(); });