From 6cdf8052e6dc4282996fc22af31633d12ea0b314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 5 Jul 2021 11:03:34 +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 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/System/Abstracts/Pool.php b/System/Abstracts/Pool.php index 82af7cc7..70620d83 100644 --- a/System/Abstracts/Pool.php +++ b/System/Abstracts/Pool.php @@ -83,6 +83,8 @@ abstract class Pool extends Component if (($length = $this->getChannel($name)->length()) > $min) { $this->debug("$length -> min length $min"); $this->flush($min); + } else { + $this->debug("$length -> min length $min"); } } } @@ -170,11 +172,10 @@ abstract class Pool extends Component */ private function getChannel($name): Channel { - $channel = static::$_items[$name] ?? new Channel(Config::get('databases.pool.max', 10)); - if (!((static::$_items[$name] ?? null) instanceof Channel)) { - static::$_items[$name] = $channel; + if (!isset(static::$_items[$name])) { + static::$_items[$name] = new Channel(Config::get('databases.pool.max', 10)); } - return $channel; + return static::$_items[$name]; } @@ -294,16 +295,14 @@ abstract class Pool extends Component /** * @param string $name * @param mixed $client + * @throws ConfigException */ public function push(string $name, mixed $client) { if (Coroutine::getCid() === -1) { return; } - $channel = static::$_items[$name] ?? new Channel($this->max); - if (!isset(static::$_items[$name])) { - static::$_items[$name] = $channel; - } + $channel = $this->getChannel($name); if (!$channel->isFull()) { $channel->push($client); }