mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-03-18 05:04:51 +08:00
add openswoole support
This commit is contained in:
parent
a757330788
commit
ee6035c59a
@ -86,7 +86,7 @@ class ZMConfig
|
||||
self::$config[$head_name] = self::loadConfig($head_name);
|
||||
}
|
||||
// global.remote_terminal
|
||||
// 根据切分来寻找子配置
|
||||
Console::debug('根据切分来寻找子配置: ' . $name);
|
||||
$obj = self::$config[$head_name];
|
||||
foreach ($separated as $key) {
|
||||
if (isset($obj[$key])) {
|
||||
|
||||
@ -6,8 +6,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace ZM\Store\Lock;
|
||||
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Coroutine\System;
|
||||
use Swoole\Table;
|
||||
|
||||
class SpinLock
|
||||
@ -28,11 +26,7 @@ class SpinLock
|
||||
public static function lock(string $key)
|
||||
{
|
||||
while (($r = self::$kv_lock->incr($key, 'lock_num')) > 1) { // 此资源已经被锁上了
|
||||
if (Coroutine::getCid() != -1) {
|
||||
System::sleep(self::$delay / 1000);
|
||||
} else {
|
||||
usleep(self::$delay * 1000);
|
||||
}
|
||||
usleep(self::$delay * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ namespace ZM\Utils;
|
||||
|
||||
use Exception;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Timer;
|
||||
use ZM\Store\LightCacheInside;
|
||||
use ZM\Store\Lock\SpinLock;
|
||||
use ZM\Store\ZMAtomic;
|
||||
@ -19,7 +20,7 @@ class CoMessage
|
||||
public static function yieldByWS(array $hang, array $compare, int $timeout = 600)
|
||||
{
|
||||
$cid = Coroutine::getuid();
|
||||
$api_id = ZMAtomic::get('wait_msg_id')->add(1);
|
||||
$api_id = ZMAtomic::get('wait_msg_id')->add();
|
||||
$hang['compare'] = $compare;
|
||||
$hang['coroutine'] = $cid;
|
||||
$hang['worker_id'] = server()->worker_id;
|
||||
@ -42,7 +43,7 @@ class CoMessage
|
||||
unset($sess[$api_id]);
|
||||
LightCacheInside::set('wait_api', 'wait_api', $sess);
|
||||
SpinLock::unlock('wait_api');
|
||||
swoole_timer_clear($id);
|
||||
Timer::clear($id);
|
||||
if ($result === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ function get_class_path(string $class_name): ?string
|
||||
*/
|
||||
function _zm_env_check()
|
||||
{
|
||||
if (!extension_loaded('swoole')) {
|
||||
if (!extension_loaded('swoole') && !extension_loaded('openswoole')) {
|
||||
exit(zm_internal_errcode('E00001') . "Can not find swoole extension.\n");
|
||||
}
|
||||
if (version_compare(SWOOLE_VERSION, '4.5.0') === -1) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user