This commit is contained in:
2020-09-09 10:44:48 +08:00
parent 8ae7ca9a18
commit 9f5ecc98ea
3 changed files with 52 additions and 6 deletions
+3 -1
View File
@@ -5,16 +5,18 @@ namespace HttpServer\IInterface;
use Closure; use Closure;
use HttpServer\Http\Request;
interface After interface After
{ {
/** /**
* @param Request $request
* @param $params * @param $params
* @param Closure|null $next * @param Closure|null $next
* @return mixed * @return mixed
*/ */
public function onHandler($params, $next); public function onHandler(Request $request, $params, $next);
} }
+3 -3
View File
@@ -29,11 +29,11 @@ class Reduce
public static function after($middleWares) public static function after($middleWares)
{ {
return array_reduce(array_reverse($middleWares), function ($stack, $pipe) { return array_reduce(array_reverse($middleWares), function ($stack, $pipe) {
return function ($passable) use ($stack, $pipe) { return function ($request, $passable) use ($stack, $pipe) {
if ($pipe instanceof After) { if ($pipe instanceof After) {
return $pipe->onHandler($passable, $stack); return $pipe->onHandler($request, $passable, $stack);
} else { } else {
return $pipe($passable, $stack); return $pipe($request, $passable, $stack);
} }
}; };
}); });
+46 -2
View File
@@ -172,5 +172,49 @@
// var_dump($value); // var_dump($value);
//} //}
exec('ps -ef 15132 | grep 15132', $output); //exec('ps -ef 15132 | grep 15132', $output);
var_dump($output); //var_dump($output);
//
//Swoole\Coroutine::create(function () {
// var_dump(\Swoole\Coroutine::getCid());
////
//// Swoole\Coroutine::create(function () {
//// var_dump(\Swoole\Coroutine::getPcid());
//// Swoole\Coroutine::create(function () {
//// var_dump(\Swoole\Coroutine::getPcid());
//// Swoole\Coroutine::create(function () {
//// var_dump(\Swoole\Coroutine::getPcid());
//// Swoole\Coroutine::create(function () {
//// var_dump(\Swoole\Coroutine::getPcid());
//// });
//// });
//// });
//// });
// Swoole\Coroutine::create(function () {
// var_dump(\Swoole\Coroutine::getPcid());
// });
// Swoole\Coroutine::create(function () {
// var_dump(\Swoole\Coroutine::getPcid());
// });
// Swoole\Coroutine::create(function () {
// var_dump(\Swoole\Coroutine::getPcid());
// });
//});
Swoole\Coroutine::create(function () {
class b
{
public function et()
{
var_dump(\Swoole\Coroutine::getPcid(), microtime(true));
\Swoole\Coroutine::sleep(0.01);
}
}
for ($a = 0; $a < 10; $a++) {
Swoole\Coroutine::create([new b(), 'et']);
}
});