diff --git a/src/Pool/AbstractPool.php b/src/Pool/AbstractPool.php index e4c277f..7f87ae4 100644 --- a/src/Pool/AbstractPool.php +++ b/src/Pool/AbstractPool.php @@ -27,7 +27,7 @@ abstract protected function createObject() ; public function __construct($maxNum = 10) { $this->queue = new \SplQueue(); - $this->chan = new Channel(); + $this->chan = new Channel(128); $this->max = $maxNum; } @@ -67,6 +67,10 @@ public function getObj(float $timeout = 0.1) $key = spl_object_hash($obj); //标记这个对象已经出队列了 $this->objHash[$key] = true; + //清空channel + while (!$this->queue->isEmpty()){ + $this->queue->pop(0.00001); + } return $obj; }else{ $this->createdNum--;