This commit is contained in:
as2252258@163.com
2021-02-23 00:39:45 +08:00
parent 09b6c29a84
commit e053deae39
2 changed files with 10 additions and 6 deletions
+9 -6
View File
@@ -49,12 +49,12 @@ abstract class Pool extends Component
} }
/** /**
* @param $name * @param $name
* @param array $callback * @param array $callback
* @return array * @return array
* @throws Exception * @throws Exception
*/ */
protected function get($name, array $callback): mixed protected function get($name, array $callback): mixed
{ {
if (!Context::inCoroutine()) { if (!Context::inCoroutine()) {
@@ -179,6 +179,9 @@ abstract class Pool extends Component
if (!Context::inCoroutine()) { if (!Context::inCoroutine()) {
return; return;
} }
if (!isset($this->_items[$name])) {
$this->_items[$name] = new Channel($this->max);
}
if (!$this->_items[$name]->isFull()) { if (!$this->_items[$name]->isFull()) {
$this->_items[$name]->push($client); $this->_items[$name]->push($client);
} }
+1
View File
@@ -26,6 +26,7 @@ class ObjectPool extends \Snowflake\Abstracts\Pool
public function getConnection(array $config, bool $isMaster): mixed public function getConnection(array $config, bool $isMaster): mixed
{ {
$config[0] = md5($config[0]); $config[0] = md5($config[0]);
$this->max = 100;
return $this->get($config[0], $config); return $this->get($config[0], $config);
} }