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:
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.
To yield every frame you have to call yield inside the loop not after the loop is finished
yield only yields the current coroutine not another one (which wouldn't be possible given the lua interpreter in wow is single threaded, which you can be thankful for otherwise we'd have locking issues)
I have a lib named Scorpio, it has a task schedule system works like:
With the system, we can avoid the callback hell and keep any logic in one function. And the better part of the system is if we put all hard works to it, it really can smooth the function calls(delay the call if there is too much operations in one phase) and make the fps no dropping.
So, if you are interesting, you can find the lib at https://github.com/kurapica/Scorpio, it's also uploaded to the curseforge.
For your example, you may check the Next and Continue API provided by the Scoprio, the Next is used to delay the process to the next phase, the Continue is used to check if there is enough time in the current phase to continue the process, otherwise, it'd delay it to the next phase.
|All times are GMT -6. The time now is 09:32 AM.|
vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI