This commit is contained in:
2021-04-15 11:57:52 +08:00
parent c49091b13e
commit df07ad18e2
+9 -16
View File
@@ -5,14 +5,9 @@ namespace Snowflake\Abstracts;
use Exception; use Exception;
use HttpServer\Http\Context; use HttpServer\Http\Context;
use JetBrains\PhpStorm\Pure; use JetBrains\PhpStorm\Pure;
use Phalcon\Mvc\Model\Query\Lang;
use Snowflake\Event;
use Snowflake\Exception\ComponentException;
use Snowflake\Exception\ConfigException; use Snowflake\Exception\ConfigException;
use Snowflake\Snowflake;
use Swoole\Coroutine; use Swoole\Coroutine;
use Swoole\Coroutine\Channel; use Swoole\Coroutine\Channel;
use Swoole\Timer; use Swoole\Timer;
@@ -52,17 +47,15 @@ abstract class Pool extends Component
public function Heartbeat_detection() public function Heartbeat_detection()
{ {
if (env('state') == 'exit') { if (env('state') == 'exit') {
$this->flush(0); Timer::clear($this->creates);
return; $this->creates = -1;
} } else if ($this->lastTime != 0) {
if ($this->lastTime == 0) { [$firstClear, $lastClear] = $this->getClearTime();
return; if ($this->lastTime + $firstClear < time()) {
} $this->flush(0);
[$firstClear, $lastClear] = $this->getClearTime(); } else if ($this->lastTime + $lastClear < time()) {
if ($this->lastTime + $firstClear < time()) { $this->flush(2);
$this->flush(0); }
} else if ($this->lastTime + $lastClear < time()) {
$this->flush(2);
} }
} }