From c0a2476e7c4f07e0a180648bad5dbe3f19b61b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 17 Feb 2021 00:06:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Abstracts/Pool.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/System/Abstracts/Pool.php b/System/Abstracts/Pool.php index 03074a83..663ef8ab 100644 --- a/System/Abstracts/Pool.php +++ b/System/Abstracts/Pool.php @@ -45,7 +45,6 @@ abstract class Pool extends Component } - /** * @param $name * @return array @@ -68,7 +67,6 @@ abstract class Pool extends Component } - /** * @param $cds * @param false $isMaster @@ -126,13 +124,13 @@ abstract class Pool extends Component */ public function createConnect(array $config, string $coroutineName, callable $createHandler): PDO|Redis|false { - if (Context::hasContext('create:connect:' . $coroutineName)) { - while (($client = Context::getContext($coroutineName)) != null){ - var_dump($client); - } - var_dump($client); + if ($client = Context::getContext($coroutineName)) { return $client; } + if (Context::hasContext('create:connect:' . $coroutineName)) { + Coroutine::sleep(0.001); + return $this->createConnect($config, $coroutineName, $createHandler); + } Context::setContext('create:connect:' . $coroutineName, 1); $client = call_user_func($createHandler, ...$config);