改名
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
namespace Server;
|
namespace Server;
|
||||||
|
|
||||||
|
|
||||||
|
use JetBrains\PhpStorm\Pure;
|
||||||
use Swoole\Coroutine\Channel;
|
use Swoole\Coroutine\Channel;
|
||||||
|
|
||||||
class ApplicationStore
|
class ApplicationStore
|
||||||
@@ -23,9 +24,9 @@ class ApplicationStore
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Server\ApplicationStore|null
|
* @return ApplicationStore|null
|
||||||
*/
|
*/
|
||||||
public static function getStore()
|
public static function getStore(): ?ApplicationStore
|
||||||
{
|
{
|
||||||
if (!(static::$applicationStore instanceof ApplicationStore)) {
|
if (!(static::$applicationStore instanceof ApplicationStore)) {
|
||||||
static::$applicationStore = new ApplicationStore();
|
static::$applicationStore = new ApplicationStore();
|
||||||
@@ -34,20 +35,32 @@ class ApplicationStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function add()
|
/**
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function add(): static
|
||||||
{
|
{
|
||||||
$this->lock->push(1);
|
$this->lock->push(1);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function waite()
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function waite(): void
|
||||||
{
|
{
|
||||||
|
if ($this->lock->isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->lock->pop(-1);
|
$this->lock->pop(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function done()
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function done(): void
|
||||||
{
|
{
|
||||||
$this->lock->pop();
|
$this->lock->pop();
|
||||||
}
|
}
|
||||||
@@ -56,7 +69,7 @@ class ApplicationStore
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isBusy()
|
public function isBusy(): bool
|
||||||
{
|
{
|
||||||
return !$this->lock->isEmpty();
|
return !$this->lock->isEmpty();
|
||||||
}
|
}
|
||||||
@@ -65,7 +78,7 @@ class ApplicationStore
|
|||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getStatus(): string
|
#[Pure] public function getStatus(): string
|
||||||
{
|
{
|
||||||
return env('state');
|
return env('state');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ class HTTPServerListener extends Abstracts\Server
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// defer(fn() => fire(Event::SYSTEM_RESOURCE_RELEASES));
|
// defer(fn() => fire(Event::SYSTEM_RESOURCE_RELEASES));
|
||||||
|
ApplicationStore::getStore()->waite();
|
||||||
|
|
||||||
/** @var \HttpServer\Http\Response $sResponse */
|
/** @var \HttpServer\Http\Response $sResponse */
|
||||||
[$sRequest, $sResponse] = $this->request($request, $response);
|
[$sRequest, $sResponse] = $this->request($request, $response);
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Server\Worker;
|
|||||||
use Annotation\Annotation;
|
use Annotation\Annotation;
|
||||||
use Exception;
|
use Exception;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
use Server\ApplicationStore;
|
||||||
use Server\Constant;
|
use Server\Constant;
|
||||||
use Snowflake\Abstracts\Config;
|
use Snowflake\Abstracts\Config;
|
||||||
use Snowflake\Core\Help;
|
use Snowflake\Core\Help;
|
||||||
@@ -33,6 +34,9 @@ class ServerWorker extends \Server\Abstracts\Server
|
|||||||
public function onWorkerStart(Server $server, int $workerId)
|
public function onWorkerStart(Server $server, int $workerId)
|
||||||
{
|
{
|
||||||
$this->_setConfigCache($workerId);
|
$this->_setConfigCache($workerId);
|
||||||
|
|
||||||
|
$store = ApplicationStore::getStore()->add();
|
||||||
|
|
||||||
$annotation = Snowflake::app()->getAnnotation();
|
$annotation = Snowflake::app()->getAnnotation();
|
||||||
$annotation->read(APP_PATH . 'app');
|
$annotation->read(APP_PATH . 'app');
|
||||||
|
|
||||||
@@ -40,6 +44,8 @@ class ServerWorker extends \Server\Abstracts\Server
|
|||||||
|
|
||||||
$this->workerInitExecutor($server, $annotation, $workerId);
|
$this->workerInitExecutor($server, $annotation, $workerId);
|
||||||
$this->interpretDirectory($annotation);
|
$this->interpretDirectory($annotation);
|
||||||
|
|
||||||
|
$store->done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user