改名
This commit is contained in:
+3
-6
@@ -56,22 +56,19 @@ class Gii
|
|||||||
*/
|
*/
|
||||||
public function run(?Connection $db, $input): array
|
public function run(?Connection $db, $input): array
|
||||||
{
|
{
|
||||||
return [
|
|
||||||
go(function () use ($db, $input) {
|
|
||||||
return $this->gen($input, $db);
|
return $this->gen($input, $db);
|
||||||
})
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $input
|
* @param $input
|
||||||
* @param $db
|
* @param $db
|
||||||
* @return array|string[]
|
* @return array
|
||||||
* @throws ComponentException
|
* @throws ComponentException
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function gen($input, $db)
|
public function gen($input, $db): array
|
||||||
{
|
{
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
if (!empty($db)) $this->db = $db;
|
if (!empty($db)) $this->db = $db;
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ abstract class Pool extends Component
|
|||||||
if (isset($this->_items[$name]) && $this->_items[$name] instanceof Channel) {
|
if (isset($this->_items[$name]) && $this->_items[$name] instanceof Channel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!Context::inCoroutine()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->_items[$name] = new Channel((int)$max);
|
$this->_items[$name] = new Channel((int)$max);
|
||||||
$this->max = (int)$max;
|
$this->max = (int)$max;
|
||||||
}
|
}
|
||||||
@@ -46,6 +49,9 @@ abstract class Pool extends Component
|
|||||||
*/
|
*/
|
||||||
protected function get($name): array
|
protected function get($name): array
|
||||||
{
|
{
|
||||||
|
if (!Context::inCoroutine()) {
|
||||||
|
return [0, null];
|
||||||
|
}
|
||||||
[$timeout, $connection] = $this->_items[$name]->pop(30);
|
[$timeout, $connection] = $this->_items[$name]->pop(30);
|
||||||
if (!$this->checkCanUse($name, $timeout, $connection)) {
|
if (!$this->checkCanUse($name, $timeout, $connection)) {
|
||||||
unset($client);
|
unset($client);
|
||||||
@@ -144,6 +150,9 @@ abstract class Pool extends Component
|
|||||||
*/
|
*/
|
||||||
public function size(string $name): mixed
|
public function size(string $name): mixed
|
||||||
{
|
{
|
||||||
|
if (!Context::inCoroutine()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!isset($this->_items[$name])) {
|
if (!isset($this->_items[$name])) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -157,6 +166,9 @@ abstract class Pool extends Component
|
|||||||
*/
|
*/
|
||||||
public function push(string $name, mixed $client)
|
public function push(string $name, mixed $client)
|
||||||
{
|
{
|
||||||
|
if (!Context::inCoroutine()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$this->_items[$name]->isFull()) {
|
if (!$this->_items[$name]->isFull()) {
|
||||||
$this->_items[$name]->push([time(), $client]);
|
$this->_items[$name]->push([time(), $client]);
|
||||||
}
|
}
|
||||||
@@ -170,6 +182,9 @@ abstract class Pool extends Component
|
|||||||
*/
|
*/
|
||||||
public function clean(string $name)
|
public function clean(string $name)
|
||||||
{
|
{
|
||||||
|
if (!Context::inCoroutine()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isset($this->_items[$name])) {
|
if (!isset($this->_items[$name])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user