This commit is contained in:
2021-03-03 10:15:16 +08:00
parent 394e936292
commit 4bd4db9f9b
3 changed files with 0 additions and 111 deletions
-72
View File
@@ -51,11 +51,6 @@ abstract class BaseApplication extends Service
use TraitApplication;
private int $state = SWOOLE_WORKER_IDLE;
private int $taskNumber = 0;
/**
* @var string
*/
@@ -84,73 +79,6 @@ abstract class BaseApplication extends Service
}
/**
* @return bool
*/
public function isRun(): bool
{
return $this->taskNumber > 0;
}
/**
* @return $this
*/
public function stateInit(): static
{
$this->taskNumber = 0;
$this->state = SWOOLE_WORKER_IDLE;
return $this;
}
/**
* @return $this
* @throws ComponentException
*/
public function decrement(): static
{
$this->taskNumber -= 1;
if ($this->taskNumber <= 0) {
$this->taskNumber = 0;
$this->state = SWOOLE_WORKER_IDLE;
} else {
$this->state = SWOOLE_WORKER_BUSY;
}
return $this->print_task_is_idle(__METHOD__);
}
/**
* @param $method
* @return BaseApplication
* @throws ComponentException
*/
private function print_task_is_idle($method): static
{
$this->warning(sprintf('%s %s:%d state %d has number %d', $method, Snowflake::getEnvironmental(), env('worker'), $this->state, $this->taskNumber));
return $this;
}
/**
* @return $this
* @throws ComponentException
*/
public function increment(): static
{
$this->taskNumber += 1;
if ($this->taskNumber < 1) {
$this->taskNumber = 0;
$this->state = SWOOLE_WORKER_IDLE;
} else {
$this->state = SWOOLE_WORKER_BUSY;
}
return $this->print_task_is_idle(__METHOD__);
}
/**
* @return array
*/