diff --git a/HttpServer/IInterface/After.php b/HttpServer/IInterface/After.php index 3a5db710..bd65a6c5 100644 --- a/HttpServer/IInterface/After.php +++ b/HttpServer/IInterface/After.php @@ -5,16 +5,18 @@ namespace HttpServer\IInterface; use Closure; +use HttpServer\Http\Request; interface After { /** + * @param Request $request * @param $params * @param Closure|null $next * @return mixed */ - public function onHandler($params, $next); + public function onHandler(Request $request, $params, $next); } diff --git a/HttpServer/Route/Reduce.php b/HttpServer/Route/Reduce.php index 544f4532..5c507a43 100644 --- a/HttpServer/Route/Reduce.php +++ b/HttpServer/Route/Reduce.php @@ -29,11 +29,11 @@ class Reduce public static function after($middleWares) { 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) { - return $pipe->onHandler($passable, $stack); + return $pipe->onHandler($request, $passable, $stack); } else { - return $pipe($passable, $stack); + return $pipe($request, $passable, $stack); } }; }); diff --git a/p.php b/p.php index 46a94911..3eadb94b 100644 --- a/p.php +++ b/p.php @@ -172,5 +172,49 @@ // var_dump($value); //} -exec('ps -ef 15132 | grep 15132', $output); -var_dump($output); +//exec('ps -ef 15132 | grep 15132', $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']); + } +});