2015-09-28 05:46:57 +02:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
2018-11-01 09:36:21 +01:00
|
|
|
require \dirname(__DIR__) . '/vendor/autoload.php';
|
2015-09-28 05:46:57 +02:00
|
|
|
|
2018-11-01 09:36:21 +01:00
|
|
|
use Amp\Parallel\Worker\CallableTask;
|
2017-05-18 09:51:31 +02:00
|
|
|
use Amp\Parallel\Worker\DefaultWorkerFactory;
|
2015-09-28 05:46:57 +02:00
|
|
|
|
2017-03-16 23:03:59 +01:00
|
|
|
Amp\Loop::run(function () {
|
2015-12-05 08:09:42 +01:00
|
|
|
$factory = new DefaultWorkerFactory();
|
2015-09-28 05:46:57 +02:00
|
|
|
|
|
|
|
$worker = $factory->create();
|
|
|
|
|
2018-11-08 21:29:07 +01:00
|
|
|
$result = yield $worker->enqueue(new CallableTask('file_get_contents', ['https://google.com']));
|
2018-10-07 16:50:45 +02:00
|
|
|
\printf("Read %d bytes\n", \strlen($result));
|
2015-09-28 05:46:57 +02:00
|
|
|
|
2016-08-18 18:04:48 +02:00
|
|
|
$code = yield $worker->shutdown();
|
2018-10-07 16:50:45 +02:00
|
|
|
\printf("Code: %d\n", $code);
|
2017-03-16 23:03:59 +01:00
|
|
|
});
|