改名
This commit is contained in:
@@ -155,7 +155,6 @@ class Loader extends BaseObject
|
||||
* @param string $namespace
|
||||
* @return ReflectionClass|null
|
||||
* @throws ReflectionException
|
||||
* @throws NotFindClassException
|
||||
*/
|
||||
private function getReflect(DirectoryIterator $path, string $namespace): ?ReflectionClass
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Server;
|
||||
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Swoole\Coroutine\Channel;
|
||||
use const Grpc\CHANNEL_SHUTDOWN;
|
||||
|
||||
class ApplicationStore
|
||||
{
|
||||
@@ -22,7 +23,7 @@ class ApplicationStore
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->lock = new Channel(99999);
|
||||
$this->lock = new Channel(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +42,8 @@ class ApplicationStore
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function add(): static
|
||||
public function instance(): static
|
||||
{
|
||||
$this->lock->push(1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -53,13 +53,20 @@ class ApplicationStore
|
||||
*/
|
||||
public function waite(): void
|
||||
{
|
||||
if ($this->lock->isEmpty()) {
|
||||
if ($this->lock->errCode == SWOOLE_CHANNEL_CLOSED) {
|
||||
return;
|
||||
}
|
||||
$this->lock->pop(-1);
|
||||
}
|
||||
|
||||
|
||||
public function close()
|
||||
{
|
||||
$this->lock->push(1);
|
||||
$this->lock->close();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -52,7 +52,6 @@ class HTTPServerListener extends Abstracts\Server
|
||||
* @param int $mode
|
||||
* @param array|null $settings
|
||||
* @return Server\Port
|
||||
* @throws NotFindClassException
|
||||
* @throws ReflectionException
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -71,7 +70,6 @@ class HTTPServerListener extends Abstracts\Server
|
||||
static::$_http->set(array_merge($settings['settings'] ?? [], ['enable_unsafe_event' => false]));
|
||||
static::$_http->on('request', [$reflect, 'onRequest']);
|
||||
static::$_http->on('connect', [$reflect, 'onConnect']);
|
||||
static::$_http->on('disconnect', [$reflect, 'onDisconnect']);
|
||||
static::$_http->on('close', [$reflect, 'onClose']);
|
||||
return static::$_http;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ class TCPServerListener extends Abstracts\Server
|
||||
|
||||
/** @var static $reflect */
|
||||
$reflect = Snowflake::getDi()->getReflect(static::class)?->newInstance();
|
||||
$reflect->setEvents(Constant::DISCONNECT, $settings['events'][Constant::DISCONNECT] ?? null);
|
||||
$reflect->setEvents(Constant::CLOSE, $settings['events'][Constant::CLOSE] ?? null);
|
||||
$reflect->setEvents(Constant::RECEIVE, $settings['events'][Constant::RECEIVE] ?? null);
|
||||
$reflect->setEvents(Constant::CONNECT, $settings['events'][Constant::CONNECT] ?? null);
|
||||
@@ -56,25 +55,10 @@ class TCPServerListener extends Abstracts\Server
|
||||
static::$_tcp->on('receive', [$reflect, 'onReceive']);
|
||||
static::$_tcp->on('connect', [$reflect, 'onConnect']);
|
||||
static::$_tcp->on('close', [$reflect, 'onClose']);
|
||||
static::$_tcp->on('disconnect', [$reflect, 'onDisconnect']);
|
||||
return static::$_tcp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param int $fd
|
||||
* @param int|null $reactor_id
|
||||
* @throws Exception
|
||||
*/
|
||||
public function onDisconnect(Server $server, int $fd, ?int $reactor_id = null)
|
||||
{
|
||||
$this->runEvent(Constant::HANDSHAKE, null, [$server, $fd, $reactor_id]);
|
||||
|
||||
$this->_event->dispatch(Event::SYSTEM_RESOURCE_RELEASES);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param int $fd
|
||||
|
||||
@@ -35,7 +35,7 @@ class ServerWorker extends \Server\Abstracts\Server
|
||||
{
|
||||
$this->_setConfigCache($workerId);
|
||||
|
||||
$store = ApplicationStore::getStore()->add();
|
||||
$store = ApplicationStore::getStore()->instance();
|
||||
|
||||
$annotation = Snowflake::app()->getAnnotation();
|
||||
$annotation->read(APP_PATH . 'app');
|
||||
@@ -50,7 +50,7 @@ class ServerWorker extends \Server\Abstracts\Server
|
||||
$this->workerInitExecutor($server, $annotation, $workerId);
|
||||
$this->interpretDirectory($annotation);
|
||||
|
||||
$store->done();
|
||||
$store->close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user