From 2b2cd508d7342e7b32467ecf92513ef902270298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 27 Apr 2021 17:49:09 +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 | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/System/Abstracts/Pool.php b/System/Abstracts/Pool.php index e32d995f..56335581 100644 --- a/System/Abstracts/Pool.php +++ b/System/Abstracts/Pool.php @@ -168,15 +168,16 @@ abstract class Pool extends Component if (!Context::inCoroutine()) { return $this->createClient($name, $callback); } -// if ($this->_items[$name]->length() > 10) { -// $connection = $this->_items[$name]->pop(); -// if (!$this->checkCanUse($name, $connection)) { -// return $this->createClient($name, $callback); -// } else { -// return $connection; -// } -// } - return $this->createClient($name, $callback); + $channel = $this->_items[$name]; + if ($channel->isEmpty()) { + return $this->createByCallback($name, $callback); + } + $connection = $channel->pop(0.002); + if (!$this->checkCanUse($name, $connection)) { + return $this->createClient($name, $callback); + } else { + return $connection; + } }