1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 09:37:57 +01:00
parallel/examples/worker.php
Aaron Piotrowski b654463339
Fix code style
2018-10-07 09:50:45 -05:00

19 lines
496 B
PHP
Executable File

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