mirror of
https://github.com/Qsgs-Fans/FreeKill.git
synced 2024-11-16 11:42:45 +08:00
b75d8afe62
简单协程调度器的实现,详细说明请看 docs/dev/scheduler.rst
40 lines
912 B
Lua
40 lines
912 B
Lua
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
---@diagnostic disable: lowercase-global
|
|
inspect = require "inspect"
|
|
dbg = require "debugger"
|
|
|
|
function PrintWhere()
|
|
local info = debug.getinfo(2)
|
|
local name = info.name
|
|
local line = info.currentline
|
|
local namewhat = info.namewhat
|
|
local shortsrc = info.short_src
|
|
if (namewhat == "method") and
|
|
(shortsrc ~= "[C]") and
|
|
(not string.find(shortsrc, "/lib")) then
|
|
print(shortsrc .. ":" .. line .. ": " .. name)
|
|
end
|
|
end
|
|
--debug.sethook(PrintWhere, "l")
|
|
|
|
function Traceback()
|
|
print(debug.traceback())
|
|
end
|
|
|
|
local msgh = function(err)
|
|
fk.qCritical(err)
|
|
print(debug.traceback(nil, 2))
|
|
end
|
|
|
|
function Pcall(f, ...)
|
|
local ret = { xpcall(f, msgh, ...) }
|
|
local err = table.remove(ret, 1)
|
|
if err ~= false then
|
|
return table.unpack(ret)
|
|
end
|
|
end
|
|
|
|
function p(v) print(inspect(v)) end
|
|
function pt(t) for k, v in pairs(t) do print(k, v) end end
|