1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-26 20:34:40 +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 AsyncInterop\Loop;
Loop::execute(function () {
Loop::execute(Amp\wrap(function () {
$timer = Loop::repeat(1000, function () {
static $i;
$i = $i ? ++$i : 1;
@ -41,4 +41,4 @@ Loop::execute(function () {
} finally {
Loop::cancel($timer);
}
});
}));

View File

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

View File

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