pass sharedtable match

This commit is contained in:
zixun
2019-06-15 11:26:40 +08:00
committed by 云风
parent 6803f45aa1
commit e9581adfc4
2 changed files with 17 additions and 3 deletions

View File

@@ -54,6 +54,17 @@ mark_shared(lua_State *L) {
} }
} }
static int
lis_sharedtable(lua_State* L) {
int b = 0;
if(lua_type(L, 1) == LUA_TTABLE) {
Table * t = (Table *)lua_topointer(L, 1);
b = isshared(t);
}
lua_pushboolean(L, b);
return 1;
}
static int static int
make_matrix(lua_State *L) { make_matrix(lua_State *L) {
// turn off gc , because marking shared will prevent gc mark. // turn off gc , because marking shared will prevent gc mark.
@@ -212,6 +223,7 @@ luaopen_skynet_sharetable_core(lua_State *L) {
luaL_Reg l[] = { luaL_Reg l[] = {
{ "clone", clone_table }, { "clone", clone_table },
{ "matrix", matrix_from_file }, { "matrix", matrix_from_file },
{ "is_sharedtable", lis_sharedtable },
{ NULL, NULL }, { NULL, NULL },
}; };
luaL_newlib(L, l); luaL_newlib(L, l);

View File

@@ -1,6 +1,7 @@
local skynet = require "skynet" local skynet = require "skynet"
local service = require "skynet.service" local service = require "skynet.service"
local core = require "skynet.sharetable.core" local core = require "skynet.sharetable.core"
local is_sharedtable = core.is_sharedtable
local function sharetable_service() local function sharetable_service()
local skynet = require "skynet" local skynet = require "skynet"
@@ -218,6 +219,7 @@ local getupvalue = debug.getupvalue
local setupvalue = debug.setupvalue local setupvalue = debug.setupvalue
local getlocal = debug.getlocal local getlocal = debug.getlocal
local setlocal = debug.setlocal local setlocal = debug.setlocal
local getinfo = debug.getinfo
local NILOBJ = {} local NILOBJ = {}
local function insert_replace(old_t, new_t, replace_map) local function insert_replace(old_t, new_t, replace_map)
@@ -257,7 +259,7 @@ local function resolve_replace(replace_map)
assert(v ~= nil) assert(v ~= nil)
local tv = type(v) local tv = type(v)
local f = match[tv] local f = match[tv]
if record_map[v] then if record_map[v] or is_sharedtable(v) then
return return
end end
@@ -339,14 +341,14 @@ local function resolve_replace(replace_map)
end end
local function match_function(f) local function match_function(f)
local info = debug.getinfo(f) local info = getinfo(f, "uf")
match_funcinfo(info) match_funcinfo(info)
end end
local function match_thread(co) local function match_thread(co)
local level = 1 local level = 1
while true do while true do
local info = debug.getinfo(co, level) local info = getinfo(co, level, "uf")
if not info then if not info then
break break
end end