mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
skynet.pcall support vararg; sharedata loader can use custom args
This commit is contained in:
@@ -28,12 +28,12 @@ function sharedata.query(name)
|
|||||||
return r
|
return r
|
||||||
end
|
end
|
||||||
|
|
||||||
function sharedata.new(name, v)
|
function sharedata.new(name, v, ...)
|
||||||
skynet.call(service, "lua", "new", name, v)
|
skynet.call(service, "lua", "new", name, v, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
function sharedata.update(name, v)
|
function sharedata.update(name, v, ...)
|
||||||
skynet.call(service, "lua", "update", name, v)
|
skynet.call(service, "lua", "update", name, v, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
function sharedata.delete(name)
|
function sharedata.delete(name)
|
||||||
|
|||||||
@@ -611,14 +611,14 @@ local function ret(f, ...)
|
|||||||
return ...
|
return ...
|
||||||
end
|
end
|
||||||
|
|
||||||
local function init_template(start)
|
local function init_template(start, ...)
|
||||||
init_all()
|
init_all()
|
||||||
init_func = {}
|
init_func = {}
|
||||||
return ret(init_all, start())
|
return ret(init_all, start(...))
|
||||||
end
|
end
|
||||||
|
|
||||||
function skynet.pcall(start)
|
function skynet.pcall(start, ...)
|
||||||
return xpcall(init_template, debug.traceback, start)
|
return xpcall(init_template, debug.traceback, start, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
function skynet.init_service(start)
|
function skynet.init_service(start)
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ local CMD = {}
|
|||||||
|
|
||||||
local env_mt = { __index = _ENV }
|
local env_mt = { __index = _ENV }
|
||||||
|
|
||||||
function CMD.new(name, t)
|
function CMD.new(name, t, ...)
|
||||||
local dt = type(t)
|
local dt = type(t)
|
||||||
local value
|
local value
|
||||||
if dt == "table" then
|
if dt == "table" then
|
||||||
@@ -51,7 +51,7 @@ function CMD.new(name, t)
|
|||||||
else
|
else
|
||||||
f = assert(load(t, "=" .. name, "bt", value))
|
f = assert(load(t, "=" .. name, "bt", value))
|
||||||
end
|
end
|
||||||
local _, ret = assert(skynet.pcall(f))
|
local _, ret = assert(skynet.pcall(f, ...))
|
||||||
setmetatable(value, nil)
|
setmetatable(value, nil)
|
||||||
if type(ret) == "table" then
|
if type(ret) == "table" then
|
||||||
value = ret
|
value = ret
|
||||||
@@ -90,7 +90,7 @@ function CMD.confirm(cobj)
|
|||||||
return NORET
|
return NORET
|
||||||
end
|
end
|
||||||
|
|
||||||
function CMD.update(name, t)
|
function CMD.update(name, t, ...)
|
||||||
local v = pool[name]
|
local v = pool[name]
|
||||||
local watch, oldcobj
|
local watch, oldcobj
|
||||||
if v then
|
if v then
|
||||||
@@ -101,7 +101,7 @@ function CMD.update(name, t)
|
|||||||
pool[name] = nil
|
pool[name] = nil
|
||||||
pool_count[name] = nil
|
pool_count[name] = nil
|
||||||
end
|
end
|
||||||
CMD.new(name, t)
|
CMD.new(name, t, ...)
|
||||||
local newobj = pool[name].obj
|
local newobj = pool[name].obj
|
||||||
if watch then
|
if watch then
|
||||||
sharedata.host.markdirty(oldcobj)
|
sharedata.host.markdirty(oldcobj)
|
||||||
|
|||||||
Reference in New Issue
Block a user