• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] ExecuteFunc() Question

Status
Not open for further replies.
Level 12
Joined
Aug 20, 2007
Messages
866
A quick question about ExecuteFunc(), I don't have a computer with WC3 to test this

Does ExecuteFunction() start a new thread?

If I call it in a loop, will the loop continue as the function continues?

(If you know the answer, skip the example and just answer yes or no)

JASS:
globals
    integer GlobalX
endglobals

function ExampleFunction takes nothing returns nothing
    set GlobalX = 8
endfunction

function Loop takes nothing returns nothing
    local integer i = 0
    local integer x = 0
    loop
      exitwhen i == 25 //Loops end doesn't really matter
      call ExcuteFunc("ExampleFunction")
      set x = GlobalX
      if x == 8 then
        set i = 25
      endif
      set x = x + 1
      set i = i + 1
    endloop
endfunction

I hope to god it does not start a new thread, because this would cause all kinds of chaos and problems

This example is obviously a nonsensical example, but it is pretty clear I won't get the effects I am looking for if there is a new thread, and the x variable gets changed to numbers that it is not supposed to be
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
To clarify:
In this case it is the same as a normal function call:
When executing ExampleFunction, first the contents of ExampleFunction would be executed and then the engine will go back to the contents of Loop.
The only difference is that if you call TriggerSleepAction within a function that has been executed with ExecuteFunc(there are also other commands), the engine will stop with the contents of the executed function and go back to the function from which it has been executed - it will not halt that function. But when using normal function calls(and TriggerSleepAction in the called function), will halt the function from which the call was made.
 
Level 12
Joined
Aug 20, 2007
Messages
866
YAAAAAAAAAAAAAAAY!!!!!!!! My life has been saved, and now I can make a certain system that I hope will be as efficient I think it will
 
Level 12
Joined
Aug 20, 2007
Messages
866
Or not, ExecuteFunc is "slow".
You should use the Vjass feature .execute() instead, if you really care about performances issues.

Eww.. damn, ok well in a new thread I am uploading a finished system as a textfile, it has not been tested (I don't own any computers that have wc3 installed) but if anybody knows any way to improve it by not using ExecuteFunc(), that would be great, please note the whole system is designed to use as few handles as possible (if using a QUICK_TIMER() or a trigger instead of ExecuteFunc() is faster, than so be it)

The new thread will be called 'SingleTimerSystem'
 
Status
Not open for further replies.
Top