HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Calling methods in a new thread

09-27-2009, 12:18 PM#1
XieLong
Okay, I am about to create a system which needs to calculate a lot of stuff with in loops within loops within loops ... :D
And as you all know there is the OP Limit of 300.000 MicroOps in WC3.
The problem now is that I hit this limit quite often. Now is my idea to avoid this limit by calling submethods within new threads.

I know that there's also the possibility to use 0-Timers but I don't really now how to handle their asynchrony...

Now I would like to know how to create loops or methods with their own thread to avoid hitting the OP-Limit.
09-27-2009, 12:26 PM#2
Hans_Maulwurf
call SomeFunc.execute(some, arguments) //will run SomeFunc in a new thread
09-27-2009, 12:36 PM#3
Seshiro
He wanted to call methods not funcs ... but I'd say create a wrapper and call the method from it ... :P
09-27-2009, 12:55 PM#4
Vexorian
You can just use .execute on the method
Collapse JASS:
structinstance.methodname.execute( method arguments ]
09-27-2009, 02:13 PM#5
XieLong
Can I make something like this:
Collapse JASS:
structinstance.methodname.execute( method arguments )
structinstance.othermethod()
or
Collapse JASS:
structinstance.methodname.execute( method arguments )
function ( structinstance )
without problems? Or do I have to manage a snychronisation? And if yes: How would I do it?
09-27-2009, 03:30 PM#6
Vexorian
method.execute works the same as function.execute
09-27-2009, 03:44 PM#7
XieLong
I know that. But I always asks me if there isn't the problem that the next called function/method is called _before_ the executed function/method has finished. If this can't happen, everything is fine... but if it can happen, I would like to know how to manage a sequential processing of the functions/methods.
09-28-2009, 05:36 AM#8
grim001
when you call .execute() it runs that code immediately then returns to the calling function.
09-28-2009, 08:25 PM#9
XieLong
Thanks a lot. I tested it myself, it seems to behave as you said.
That's great, now I can finish the system. Thanks to everyone here, especially to Vex for this possibility :)