-
Posted by nogenius on Sat, 25 Sep 2010 18:51:54
Hi everyone,
I have an issue with my addon: It performs kind of long calculations. Whenever this calculation is triggered, WOW freezes which is not really nice. Is there a way to perform these calculations in background? Or in a parallel thread? Any other ideas are also welcome ;-)
Thanks in advance!
-
Posted by jnwhiteh on Sat, 25 Sep 2010 19:25:46
There's only one thread, so no. You can use coroutines, which are a bit like pseudo-threads. See this thread and this snippet for examples.
-
Posted by nogenius on Sun, 26 Sep 2010 10:42:06
Nice, thank you! It seems that I have searched for the wrong tags in the past... It works perfekt.
Just one more thing to understand the behavior: What happens when coroutine.resume(...) is called, but the coroutine is not yielded yet? I guess this could happen when you chose the throttle value too low. Would this mean that the coroutine is just resumed right away when the yield command comes, i.e. behavior just without the coroutine, or will the resume command just have an effect when the coroutine is yielded?
Thanks again!
-
Posted by jnwhiteh on Sun, 26 Sep 2010 13:10:11
Nice, thank you! It seems that I have searched for the wrong tags in the past... It works perfekt.
Just one more thing to understand the behavior: What happens when coroutine.resume(...) is called, but the coroutine is not yielded yet? I guess this could happen when you chose the throttle value too low. Would this mean that the coroutine is just resumed right away when the yield command comes, i.e. behavior just without the coroutine, or will the resume command just have an effect when the coroutine is yielded?
Thanks again!
That cannot ever happen. The user interface is a single thread. Either the OnUpdate handler is running, or the function is running.