I am currently writing my functions to run for N iterations before calling them again, but it would be much more convenient and consistent to be able to pass my functions off to a handler/scheduler and have them take care of them for me. This is an example of what I am trying to do:
Code:
local thread
local delay
local count = 0
local queue = function()
for a = 1, 10000000 do
count = a
end
end
C_Timer.NewTicker(0, function()
if queue then
if not thread then
thread = coroutine.create(function()
delay = C_Timer.NewTicker(0, function()
print(count)
if coroutine.status(thread) == "dead" then
queue = nil
thread = nil
delay:Cancel()
else
coroutine.yield()
end
end)
queue()
end)
end
coroutine.resume(thread)
end
end)
I was trying to pass my functions to the variable 'queue' and have them turned into coroutines that would be yielded every frame. However it seems that C_Timer.NewTicker doesn't run asynchronously, so it never gets to yield the coroutine.
Is there any way to do what I am trying to do? It seems strange to me that I can't come up with a clean way to throttle my functions. Thanks for your help.