改名
This commit is contained in:
@@ -5,7 +5,6 @@ namespace Snowflake\Abstracts;
|
||||
|
||||
|
||||
use Exception;
|
||||
use HttpServer\Http\Context;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Exception\ConfigException;
|
||||
use Swoole\Coroutine;
|
||||
@@ -173,13 +172,14 @@ abstract class Pool extends Component
|
||||
if (Coroutine::getCid() === -1) {
|
||||
return $this->createClient($name, $callback);
|
||||
}
|
||||
$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]->isEmpty()) {
|
||||
$this->createByCallback($name, $callback);
|
||||
if ($channel->isEmpty()) {
|
||||
$this->createByCallback($channel, $name, $callback);
|
||||
}
|
||||
$connection = static::$_items[$name]->pop();
|
||||
$connection = $channel->pop();
|
||||
if (!$this->checkCanUse($name, $connection)) {
|
||||
return $this->createClient($name, $callback);
|
||||
} else {
|
||||
@@ -189,16 +189,16 @@ abstract class Pool extends Component
|
||||
|
||||
|
||||
/**
|
||||
* @param $channel
|
||||
* @param $name
|
||||
* @param mixed $callback
|
||||
* @throws Exception
|
||||
*/
|
||||
private function createByCallback($name, mixed $callback): void
|
||||
private function createByCallback(Channel $channel, $name, mixed $callback): void
|
||||
{
|
||||
if ($this->creates === -1 && !is_callable($callback)) {
|
||||
$this->creates = Timer::tick(1000, [$this, 'Heartbeat_detection']);
|
||||
}
|
||||
static::$_items[$name]->push($this->createClient($name, $callback));
|
||||
$channel->push($this->createClient($name, $callback));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user