mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
add trace api to skynet.lua
This commit is contained in:
@@ -129,7 +129,7 @@ _callback(lua_State *L) {
|
|||||||
|
|
||||||
lua_createtable(L,0,1);
|
lua_createtable(L,0,1);
|
||||||
lua_pushcfunction(L, _delete_stat);
|
lua_pushcfunction(L, _delete_stat);
|
||||||
lua_setfield(L,-1,"__gc");
|
lua_setfield(L,-2,"__gc");
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
|
|
||||||
lua_rawsetp(L, LUA_REGISTRYINDEX, _stat);
|
lua_rawsetp(L, LUA_REGISTRYINDEX, _stat);
|
||||||
|
|||||||
@@ -483,8 +483,11 @@ local function init_template(start)
|
|||||||
init_all()
|
init_all()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local trace_handle
|
||||||
|
|
||||||
function skynet.start(start_func)
|
function skynet.start(start_func)
|
||||||
c.callback(dispatch_message)
|
c.callback(dispatch_message)
|
||||||
|
trace_handle = assert(c.stat "trace")
|
||||||
skynet.timeout(0, function()
|
skynet.timeout(0, function()
|
||||||
init_template(start_func)
|
init_template(start_func)
|
||||||
skynet.send(".launcher","text", "")
|
skynet.send(".launcher","text", "")
|
||||||
@@ -495,10 +498,31 @@ function skynet.filter(f ,start_func)
|
|||||||
c.callback(function(...)
|
c.callback(function(...)
|
||||||
dispatch_message(f(...))
|
dispatch_message(f(...))
|
||||||
end)
|
end)
|
||||||
|
trace_handle = assert(c.stat "trace")
|
||||||
skynet.timeout(0, function()
|
skynet.timeout(0, function()
|
||||||
init_template(start_func)
|
init_template(start_func)
|
||||||
skynet.send(".launcher","text", "")
|
skynet.send(".launcher","text", "")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function skynet.trace_new()
|
||||||
|
return c.trace_new(trace_handle)
|
||||||
|
end
|
||||||
|
|
||||||
|
function skynet.trace_delete(info)
|
||||||
|
return c.trace_delete(info)
|
||||||
|
end
|
||||||
|
|
||||||
|
function skynet.trace_switch(session)
|
||||||
|
return c.trace_switch(trace_handle, session)
|
||||||
|
end
|
||||||
|
|
||||||
|
function skynet.trace_yield()
|
||||||
|
return c.trace_yield(trace_handle)
|
||||||
|
end
|
||||||
|
|
||||||
|
function skynet.trace_register(session)
|
||||||
|
return c.trace_register(trace_handle, session)
|
||||||
|
end
|
||||||
|
|
||||||
return skynet
|
return skynet
|
||||||
|
|||||||
Reference in New Issue
Block a user