aboutsummaryrefslogtreecommitdiff
path: root/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util.lua')
-rw-r--r--util.lua20
1 files changed, 16 insertions, 4 deletions
diff --git a/util.lua b/util.lua
index e7c6cbf..7061c06 100644
--- a/util.lua
+++ b/util.lua
@@ -4,16 +4,28 @@ function lua_async.yield()
end))
end
-function lua_async.kill_thread()
- coroutine.yield(true)
-end
-
function lua_async.sleep(ms)
await(Promise(function(resolve)
setTimeout(resolve, ms)
end))
end
+function lua_async.kill_thread()
+ coroutine.yield(true)
+end
+
+function lua_async.resume(co)
+ local status, err = coroutine.resume(co)
+
+ if coroutine.status(co) == "dead" or err then
+ lua_async.limiting.unset_limit(co)
+ end
+
+ if not status then
+ error("Error (in async function): " .. err)
+ end
+end
+
function lua_async.run()
local last_time = os.clock()