1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-30 04:39:01 +01:00

Update examples

This commit is contained in:
Aaron Piotrowski 2017-02-18 11:06:03 -06:00
parent 0912d39004
commit d6a1b19b8e
3 changed files with 7 additions and 7 deletions

View File

@ -6,7 +6,7 @@ use Amp\Parallel\Threading\Thread;
use Amp\Pause; use Amp\Pause;
use AsyncInterop\Loop; use AsyncInterop\Loop;
Loop::execute(function () { Loop::execute(Amp\wrap(function () {
$timer = Loop::repeat(1000, function () { $timer = Loop::repeat(1000, function () {
static $i; static $i;
$i = $i ? ++$i : 1; $i = $i ? ++$i : 1;
@ -41,4 +41,4 @@ Loop::execute(function () {
} finally { } finally {
Loop::cancel($timer); Loop::cancel($timer);
} }
}); }));

View File

@ -2,9 +2,8 @@
<?php <?php
require dirname(__DIR__).'/vendor/autoload.php'; require dirname(__DIR__).'/vendor/autoload.php';
use Amp\Parallel\Worker\DefaultPool;
use Amp\Coroutine; use Amp\Coroutine;
use Amp\Parallel\Example\BlockingTask; use Amp\Parallel\{ Example\BlockingTask, Worker\DefaultPool };
use AsyncInterop\Loop; use AsyncInterop\Loop;
Loop::execute(Amp\wrap(function() { Loop::execute(Amp\wrap(function() {
@ -13,7 +12,7 @@ Loop::execute(Amp\wrap(function() {
}); });
Loop::unreference($timer); Loop::unreference($timer);
$pool = new DefaultPool(); $pool = new DefaultPool;
$pool->start(); $pool->start();
$coroutines = []; $coroutines = [];

View File

@ -4,8 +4,9 @@ require dirname(__DIR__).'/vendor/autoload.php';
use Amp\Parallel\Worker\DefaultWorkerFactory; use Amp\Parallel\Worker\DefaultWorkerFactory;
use Amp\Parallel\Example\BlockingTask; use Amp\Parallel\Example\BlockingTask;
use AsyncInterop\Loop;
Amp\execute(function () { Loop::execute(Amp\wrap(function () {
$factory = new DefaultWorkerFactory(); $factory = new DefaultWorkerFactory();
$worker = $factory->create(); $worker = $factory->create();
@ -16,4 +17,4 @@ Amp\execute(function () {
$code = yield $worker->shutdown(); $code = yield $worker->shutdown();
printf("Code: %d\n", $code); printf("Code: %d\n", $code);
}); }));