1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-26 20:34:40 +01:00
parallel/examples/worker-process.php
2015-08-27 09:10:08 -05:00

22 lines
498 B
PHP
Executable File

#!/usr/bin/env php
<?php
require dirname(__DIR__).'/vendor/autoload.php';
use Icicle\Concurrent\Worker\HelloTask;
use Icicle\Concurrent\Worker\WorkerProcess;
use Icicle\Coroutine;
use Icicle\Loop;
Coroutine\create(function () {
$worker = new WorkerProcess();
$worker->start();
$returnValue = (yield $worker->enqueue(new HelloTask()));
printf("Return value: %s\n", $returnValue);
$code = (yield $worker->shutdown());
printf("Code: %d\n", $code);
})->done();
Loop\run();