From 00ee4651b9bb5b669bfe993038c934b38b99ef22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 5 Apr 2023 19:58:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiri-engine/Pool/PoolItem.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kiri-engine/Pool/PoolItem.php b/kiri-engine/Pool/PoolItem.php index d2f0c637..25402ab3 100644 --- a/kiri-engine/Pool/PoolItem.php +++ b/kiri-engine/Pool/PoolItem.php @@ -101,13 +101,13 @@ class PoolItem */ public function pop(int $waite = 10): mixed { - if ($this->_items->isEmpty() && $this->created < $this->maxCreated) { - $client = call_user_func($this->callback); - - $this->created += 1; - - return $client; + if (!$this->_items->isEmpty()) { + return $this->_items->pop(); } - return $this->_items->pop($waite); + if ($this->created > $this->maxCreated) { + return $this->_items->pop($waite); + } + $this->created += 1; + return call_user_func($this->callback); } }