This commit is contained in:
2021-04-27 17:04:22 +08:00
parent 19835dba97
commit f4e13f413b
2 changed files with 11 additions and 21 deletions
+1 -5
View File
@@ -113,11 +113,7 @@ class Server extends HttpService
return 'ok';
}
Runtime::enableCoroutine(true, SWOOLE_HOOK_TCP |
SWOOLE_HOOK_UNIX | SWOOLE_HOOK_UDP | SWOOLE_HOOK_UDG |
SWOOLE_HOOK_SSL | SWOOLE_HOOK_TLS | SWOOLE_HOOK_SLEEP |
SWOOLE_HOOK_STREAM_FUNCTION | SWOOLE_HOOK_PROC
);
Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_BLOCKING_FUNCTION);
Coroutine::set(['enable_deadlock_check' => false]);
+10 -16
View File
@@ -42,27 +42,21 @@ class Service extends Component
*/
public function get($id, $try = true): mixed
{
if (isset($this->_components[$id])) {
return $this->_components[$id];
}
if (!isset($this->_definition[$id]) && !isset($this->_alias[$id])) {
if ($try === false) {
return null;
if (!isset($this->_components[$id])) {
if (!isset($this->_definition[$id])) {
throw new ComponentException("Unknown component ID: $id");
}
throw new ComponentException("Unknown component ID: $id");
}
if (isset($this->_definition[$id])) {
$config = $this->_definition[$id];
if (is_object($config)) {
return $this->_components[$id] = $config;
return $config;
}
$object = Snowflake::createObject($config);
} else {
$config = $this->_alias[$id];
$object = Snowflake::createObject($config);
$this->_components[$id] = Snowflake::createObject($config);
}
return $this->_components[$id] = $object;
$object = $this->_components[$id];
if (method_exists($object, 'afterInit')) {
$object->afterInit();
}
return $object;
}
/**