modify
This commit is contained in:
@@ -35,6 +35,8 @@ class OnWorkerStart extends Callback
|
||||
public function onHandler(Server $server, int $worker_id): void
|
||||
{
|
||||
Coroutine::set(['enable_deadlock_check' => false]);
|
||||
Snowflake::app()->stateInit();
|
||||
|
||||
if ($worker_id >= $server->setting['worker_num']) {
|
||||
$this->onTask($server, $worker_id);
|
||||
} else {
|
||||
|
||||
@@ -93,13 +93,21 @@ abstract class BaseApplication extends Service
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function stateInit()
|
||||
{
|
||||
$this->taskNumber = 0;
|
||||
$this->state = 'SWOOLE_WORKER_IDLE';
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function decrement()
|
||||
{
|
||||
$this->taskNumber -= 1;
|
||||
@@ -107,9 +115,13 @@ abstract class BaseApplication extends Service
|
||||
$this->taskNumber = 0;
|
||||
$this->state = 'SWOOLE_WORKER_IDLE';
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function increment()
|
||||
{
|
||||
$this->taskNumber += 1;
|
||||
@@ -119,7 +131,6 @@ abstract class BaseApplication extends Service
|
||||
} else {
|
||||
$this->state = 'SWOOLE_WORKER_BUSY';
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user