Implement coroutine handling
This commit is contained in:
@@ -324,10 +324,24 @@ function ApplyRules(s)
|
||||
return nil
|
||||
end
|
||||
|
||||
Coroutines = {}
|
||||
function AddCo(f)
|
||||
local i = #Coroutines + 1
|
||||
Coroutines[i] = coroutine.create(f)
|
||||
return Coroutines[i]
|
||||
end
|
||||
|
||||
|
||||
function OnUpdate()
|
||||
-- @todo: implement coroutine dispatch here
|
||||
-- probably also want constatnly rerunning jobs with a set wake up time
|
||||
-- @warning: make sure to not rewrite the thread list when rerunning this file
|
||||
local new_co_list = {}
|
||||
for key, co in pairs(Coroutines) do
|
||||
local status = coroutine.status(co)
|
||||
if status ~= "dead" then
|
||||
coroutine.resume(co)
|
||||
new_co_list[#new_co_list + 1] = co
|
||||
end
|
||||
end
|
||||
Coroutines = new_co_list
|
||||
end
|
||||
|
||||
)==";
|
||||
|
||||
Reference in New Issue
Block a user