examples -> example

This commit is contained in:
Aaron Piotrowski
2016-08-26 09:53:18 -05:00
parent 3765dcfadc
commit c38b921029
6 changed files with 1 additions and 0 deletions

19
example/worker.php Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env php
<?php
require dirname(__DIR__).'/vendor/autoload.php';
use Amp\Parallel\Worker\DefaultWorkerFactory;
use Amp\Parallel\Example\BlockingTask;
Amp\execute(function () {
$factory = new DefaultWorkerFactory();
$worker = $factory->create();
$worker->start();
$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);
});