1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-30 04:39:01 +01:00
parallel/examples/worker.php
Pieter Hordijk b9d6720c83 Fixed examples (#61)
* Fixed examples

CallableTask expects the parameters to be passed in as array

* Fixed worker-pool example

The task does not make available the arguments (anymore)
2018-11-08 14:29:07 -06:00

19 lines
499 B
PHP
Executable File

#!/usr/bin/env php
<?php
require \dirname(__DIR__) . '/vendor/autoload.php';
use Amp\Parallel\Worker\CallableTask;
use Amp\Parallel\Worker\DefaultWorkerFactory;
Amp\Loop::run(function () {
$factory = new DefaultWorkerFactory();
$worker = $factory->create();
$result = yield $worker->enqueue(new CallableTask('file_get_contents', ['https://google.com']));
\printf("Read %d bytes\n", \strlen($result));
$code = yield $worker->shutdown();
\printf("Code: %d\n", $code);
});