mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
add new api skynet.task()
This commit is contained in:
@@ -583,6 +583,17 @@ function skynet.mqlen()
|
||||
return tonumber(c.command "MQLEN")
|
||||
end
|
||||
|
||||
function skynet.task(f)
|
||||
local t = 0
|
||||
for _,co in pairs(session_id_coroutine) do
|
||||
if f then
|
||||
f(debug.traceback(co))
|
||||
end
|
||||
t = t + 1
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
-- Inject internal debug framework
|
||||
local debug = require "skynet.debug"
|
||||
debug(skynet)
|
||||
|
||||
@@ -21,9 +21,16 @@ end
|
||||
function dbgcmd.STAT()
|
||||
local stat = {}
|
||||
stat.mqlen = skynet.mqlen()
|
||||
stat.task = skynet.task()
|
||||
skynet.ret(skynet.pack(stat))
|
||||
end
|
||||
|
||||
function dbgcmd.TASK()
|
||||
local task = {}
|
||||
skynet.task(function(info) table.insert(task, info) end)
|
||||
skynet.ret(skynet.pack(task))
|
||||
end
|
||||
|
||||
function dbgcmd.INFO()
|
||||
if internal_info_func then
|
||||
skynet.ret(skynet.pack(internal_info_func()))
|
||||
|
||||
Reference in New Issue
Block a user