mirror of
https://github.com/danog/parallel.git
synced 2024-11-26 20:34:40 +01:00
b9d6720c83
* 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)
19 lines
499 B
PHP
Executable File
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);
|
|
});
|