This commit is contained in:
2021-03-02 18:33:12 +08:00
parent 0eee8d6cff
commit b2fea0250a
4 changed files with 160 additions and 118 deletions
+4 -9
View File
@@ -146,19 +146,13 @@ abstract class Pool extends Component
/**
* @param $name
* @param mixed $callback
* @throws ComponentException
* @throws Exception
*/
private function createByCallback($name, mixed $callback)
{
// if ($this->creates === -1 && !is_callable($callback)) {
// $this->creates = $creates = Timer::tick(1000, [$this, 'Heartbeat_detection']);
//
// $event = Snowflake::app()->getEvent();
// $event->on(Event::SERVER_WORKER_STOP, function () use ($creates) {
// Timer::clear($creates);
// });
// }
if ($this->creates === -1 && !is_callable($callback)) {
$this->creates = $creates = Timer::tick(1000, [$this, 'Heartbeat_detection']);
}
if (!Context::hasContext('create::client::ing::' . $name)) {
$this->push($name, $this->createClient($name, $callback));
Context::remove('create::client::ing::' . $name);
@@ -283,6 +277,7 @@ abstract class Pool extends Component
*/
public function clean(string $name)
{
Timer::clear($this->creates);
if (!Context::inCoroutine() || !isset($this->_items[$name])) {
return;
}