改名
This commit is contained in:
@@ -15,6 +15,7 @@ use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Error\Logger;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Snowflake\Snowflake;
|
||||
use Swoole\Coroutine;
|
||||
|
||||
/**
|
||||
* Class BaseObject
|
||||
@@ -39,11 +40,23 @@ class BaseObject implements Configure
|
||||
$this->init();
|
||||
}
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array|callable $callback
|
||||
* @param object $scope
|
||||
*/
|
||||
public function async_create(array|callable $callback, object $scope)
|
||||
{
|
||||
Coroutine::create($callback, $scope);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,7 @@ use Snowflake\Event;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Snowflake\Exception\NotFindClassException;
|
||||
use Snowflake\Snowflake;
|
||||
use Swoole\Coroutine;
|
||||
|
||||
/**
|
||||
* Class ObjectPool
|
||||
@@ -81,10 +82,11 @@ class ObjectPool extends \Snowflake\Abstracts\Pool
|
||||
*/
|
||||
public function destruct()
|
||||
{
|
||||
if (empty($this->_waitRecover)) {
|
||||
$this->async_create(function ($scope) {
|
||||
if (empty($scope->_waitRecover)) {
|
||||
return;
|
||||
}
|
||||
foreach ($this->_waitRecover as $name => $value) {
|
||||
foreach ($scope->_waitRecover as $name => $value) {
|
||||
if (empty($value)) {
|
||||
continue;
|
||||
}
|
||||
@@ -92,10 +94,11 @@ class ObjectPool extends \Snowflake\Abstracts\Pool
|
||||
if (method_exists($object, 'clean')) {
|
||||
$object->clean();
|
||||
}
|
||||
$this->push($name, $object);
|
||||
$scope->push($name, $object);
|
||||
}
|
||||
unset($scope->_waitRecover[$name]);
|
||||
}
|
||||
$this->_waitRecover = [];
|
||||
}, $this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user