Is there any way to throttle an arbitrary function?
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:
local count = 0
local queue = function()
for a = 1, 10000000 do
count = a
if queue then
if not thread then
thread = coroutine.create(function()
delay = C_Timer.NewTicker(0, function()
if coroutine.status(thread) == "dead" then
queue = nil
thread = nil
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.