From 6fb5bb1d412d1a72130939cad818f5dbdfa4b187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 20 May 2021 18:43:44 +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, 7 insertions(+), 5 deletions(-) diff --git a/System/Abstracts/Pool.php b/System/Abstracts/Pool.php index b8ba314a..343998a4 100644 --- a/System/Abstracts/Pool.php +++ b/System/Abstracts/Pool.php @@ -121,12 +121,12 @@ abstract class Pool extends Component /** - * @param $channel + * @param Channel $channel * @param $name * @param $retain_number * @throws Exception */ - protected function pop($channel, $name, $retain_number): void + protected function pop(Channel $channel, $name, $retain_number): void { if (Coroutine::getCid() === -1) { return; @@ -296,11 +296,12 @@ abstract class Pool extends Component if (Coroutine::getCid() === -1) { return; } + $channel = static::$_items[$name] ?? new Channel($this->max); if (!isset(static::$_items[$name])) { - static::$_items[$name] = new Channel($this->max); + static::$_items[$name] = $channel; } - if (!static::$_items[$name]->isFull()) { - static::$_items[$name]->push($client); + if (!$channel->isFull()) { + $channel->push($client); } unset($client); } @@ -320,6 +321,7 @@ abstract class Pool extends Component if ($this->creates > -1) { Timer::clear($this->creates); } + $channel->close(); static::$_items[$name] = null; }