51 lines
1.1 KiB
PHP
Executable File
51 lines
1.1 KiB
PHP
Executable File
--TEST--
|
|
swoole_coroutine: coro channel
|
|
--SKIPIF--
|
|
<?php require __DIR__ . '/../include/skipif.inc'; ?>
|
|
--FILE--
|
|
<?php
|
|
require_once __DIR__ . '/../include/bootstrap.php';
|
|
|
|
$pm = new ProcessManager;
|
|
$pm->parentFunc = function ($pid)
|
|
{
|
|
$data = curlGet("http://127.0.0.1:9501/");
|
|
echo $data;
|
|
swoole_process::kill($pid);
|
|
};
|
|
|
|
$pm->childFunc = function () use ($pm)
|
|
{
|
|
$http = new swoole_http_server("127.0.0.1", 9501, SWOOLE_BASE);
|
|
$http->set(array(
|
|
'log_file' => '/dev/null'
|
|
));
|
|
$http->on("WorkerStart", function (\swoole_server $serv)
|
|
{
|
|
/**
|
|
* @var $pm ProcessManager
|
|
*/
|
|
global $pm;
|
|
$pm->wakeup();
|
|
});
|
|
$http->on('request', function (swoole_http_request $request, swoole_http_response $response)
|
|
{
|
|
$ch = new \Swoole\Channel(1);
|
|
$out = new \Swoole\Channel(1);
|
|
Swoole\Coroutine::create(function() use ($ch, $out) {
|
|
$tmp = $ch->pop();
|
|
$out->push("OK");
|
|
});
|
|
$ch->push("test");
|
|
$ret = $out->pop();
|
|
$response->end("$ret\n");
|
|
});
|
|
$http->start();
|
|
};
|
|
|
|
$pm->childFirst();
|
|
$pm->run();
|
|
?>
|
|
--EXPECT--
|
|
OK
|