mirror of
https://github.com/danog/parallel.git
synced 2024-11-26 20:34:40 +01:00
Update examples
This commit is contained in:
parent
0912d39004
commit
d6a1b19b8e
@ -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);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
@ -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 = [];
|
||||
|
@ -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);
|
||||
});
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user