initial 2.0.0-a3 commit

This commit is contained in:
jerry
2020-10-03 23:00:18 +08:00
parent f91d24aaaa
commit da584e0542
28 changed files with 580 additions and 225 deletions

View File

@@ -15,68 +15,20 @@ use ZM\Config\ZMConfig;
class ZMBuf
{
//读写的缓存数据需要在worker_num = 1下才能正常使用
/** @var mixed[] ZMBuf的data */
private static $cache = [];
//Swoole SQL连接池多进程下每个进程一个连接池
/** @var PDOPool */
static $sql_pool = null;//保存sql连接池的类
/** @var array Http请求uri路径根节点 */
public static $req_mapping_node;
/** @var array 事件注解的绑定对 */
public static $events = [];
// 下面的有用,上面的没用了
/** @var Atomic[] */
public static $atomics;
public static $instance = [];
public static $context_class = [];
public static $terminal = null;
static function get($name, $default = null) {
return self::$cache[$name] ?? $default;
}
static function set($name, $value) {
self::$cache[$name] = $value;
}
static function append($name, $value) {
self::$cache[$name][] = $value;
}
static function appendKey($name, $key, $value) {
self::$cache[$name][$key] = $value;
}
static function appendKeyInKey($name, $key, $value) {
self::$cache[$name][$key][] = $value;
}
static function unsetCache($name) {
unset(self::$cache[$name]);
}
static function unsetByValue($name, $vale) {
$key = array_search($vale, self::$cache[$name]);
array_splice(self::$cache[$name], $key, 1);
}
static function isset($name) {
return isset(self::$cache[$name]);
}
static function array_key_exists($name, $key) {
return isset(self::$cache[$name][$key]);
}
static function in_array($name, $val) {
return in_array($val, self::$cache[$name]);
}
public static function resetCache() {
self::$cache = [];
self::$instance = [];
}
/**
* 初始化atomic计数器
*/
@@ -86,6 +38,9 @@ class ZMBuf
}
self::$atomics["stop_signal"] = new Atomic(0);
self::$atomics["wait_msg_id"] = new Atomic(0);
for($i = 0; $i < 10; ++$i) {
self::$atomics["_tmp_".$i] = new Atomic(0);
}
}
/**