summaryrefslogtreecommitdiff
path: root/server-beta/src/task.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server-beta/src/task.lua')
-rw-r--r--server-beta/src/task.lua4
1 files changed, 4 insertions, 0 deletions
diff --git a/server-beta/src/task.lua b/server-beta/src/task.lua
index 5b7fb8dd..ba7bec94 100644
--- a/server-beta/src/task.lua
+++ b/server-beta/src/task.lua
@@ -1,9 +1,12 @@
local timer = require 'timer'
+
---@class task
local m = {}
m.type = 'task'
+m.coTracker = setmetatable({}, { __mode = 'k' })
+
--- 设置错误处理器
---@param errHandle function {comment = '当有错误发生时,会以错误堆栈为参数调用该函数'}
function m.setErrorHandle(errHandle)
@@ -13,6 +16,7 @@ end
--- 创建一个任务
function m.create(callback)
local co = coroutine.create(callback)
+ m.coTracker[co] = true
local suc, err = coroutine.resume(co)
if not suc and m.errHandle then
m.errHandle(debug.traceback(co, err))