改名
This commit is contained in:
@@ -50,6 +50,12 @@ abstract class BaseApplication extends Service
|
||||
|
||||
use TraitApplication;
|
||||
|
||||
|
||||
private string $state = '';
|
||||
|
||||
|
||||
private int $taskNumber = 0;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -78,6 +84,37 @@ abstract class BaseApplication extends Service
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isRun(): bool
|
||||
{
|
||||
return $this->state == 'SWOOLE_WORKER_BUSY';
|
||||
}
|
||||
|
||||
|
||||
public function decrement()
|
||||
{
|
||||
$this->taskNumber -= 1;
|
||||
if ($this->taskNumber <= 0) {
|
||||
$this->taskNumber = 0;
|
||||
$this->state = 'SWOOLE_WORKER_IDLE';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function increment()
|
||||
{
|
||||
$this->taskNumber += 1;
|
||||
if ($this->taskNumber <= 0) {
|
||||
$this->taskNumber = 0;
|
||||
$this->state = 'SWOOLE_WORKER_IDLE';
|
||||
} else {
|
||||
$this->state = 'SWOOLE_WORKER_BUSY';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user