concurrency

Weep

Godspeed to the sound of the pounding
Reaction score
400
It...doesn't?

Can you be more specific? :D
 

tooltiperror

Super Moderator
Reaction score
231
If you mean true concurrency, it doesn't.

The Warcraft III engine is linear.
 
Reaction score
86
okay i see. So if a function is running and a timer fires off, when does warcraft 3 go to the callback of the timer? after the function is completed? or is there some special case like TriggerEvaluate or TriggerExecute or something else?
 

tooltiperror

Super Moderator
Reaction score
231
I tested it myself. This displayed:

  1. onInit runs.
  2. The timer is started.
  3. onInit terminates.
  4. The timer expires.

JASS:
//! zinc

library Concurrency
{
  
  function handlerfunc()
  {
      BJDebugMsg("The timer expires.");
  }
  
  function onInit()
  {
    timer t = CreateTimer();
      BJDebugMsg("onInit runs.");
      BJDebugMsg("The timer is started.");
      TimerStart(t, 2.00, false, function handlerfunc);
      BJDebugMsg("onInit terminates.");
  }
}

//! endzinc
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
okay i see. So if a function is running and a timer fires off, when does warcraft 3 go to the callback of the timer? after the function is completed? or is there some special case like TriggerEvaluate or TriggerExecute or something else?

Well, for timers, it will always execute after the functions succeeding the call, (assuming you don't have waits) because it has a duration applied before the callback is executed. :p Timers don't perform sleeps for the thread they are running in, they wait and then execute the callback on a new thread.

For trigger execute and trigger evaluate, they will both be performed before the succeeding functions. So, for example, this:
JASS:
scope Test initializer Init
    globals
        trigger test_0 = CreateTrigger()
        trigger test_1 = CreateTrigger()
    endglobals
    
    private function cond takes nothing returns boolean
        call BJDebugMsg("Conditions executed...")
        return false
    endfunction
    
    private function action takes nothing returns nothing
        call BJDebugMsg("Actions executed...")
    endfunction
    
    private function esc takes nothing returns nothing
        call BJDebugMsg("Executing...")
        call TriggerExecute(test_0)
        call TriggerEvaluate(test_1)
        call BJDebugMsg("Finished...")
    endfunction
    
    private function Init takes nothing returns nothing
        call TriggerAddAction(test_0,function action)
        call TriggerAddCondition(test_1,Condition(function cond))
    endfunction
endscope


Will read "Executing...", followed by "Actions executed...", "Conditions executed...", and finally "Finished...". :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top