mirror of
https://github.com/danog/parallel.git
synced 2024-11-27 04:44:56 +01:00
25 lines
611 B
PHP
Executable File
25 lines
611 B
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
require dirname(__DIR__).'/vendor/autoload.php';
|
|
|
|
use Icicle\Concurrent\Worker\HelloTask;
|
|
use Icicle\Concurrent\Worker\WorkerPool;
|
|
use Icicle\Coroutine;
|
|
use Icicle\Loop;
|
|
use Icicle\Promise;
|
|
|
|
Coroutine\create(function () {
|
|
$pool = new WorkerPool(1);
|
|
|
|
$returnValues = (yield Promise\all([
|
|
new Coroutine\Coroutine($pool->enqueue(new HelloTask())),
|
|
new Coroutine\Coroutine($pool->enqueue(new HelloTask())),
|
|
new Coroutine\Coroutine($pool->enqueue(new HelloTask())),
|
|
]));
|
|
var_dump($returnValues);
|
|
|
|
yield $pool->shutdown();
|
|
})->done();
|
|
|
|
Loop\run();
|