• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

ConditionalTriggerExecute vs TriggerEvaluate

Status
Not open for further replies.
Level 8
Joined
Jul 10, 2008
Messages
353
ConditionalTriggerExecute, with only Conditions and no actions

vs

TriggerEvaluate


Whats their difference and what is faster?

Anyone got any info on the topic?

ConditionalTriggerExecute does not open a separate thread while TriggerEvaluate opens a separate thread, thus ConditionalTriggerExecute with no actions should be faster?
 
"Tested" in the table means self-tested in past, I can't prodvide a demo atm.


TriggerAction
TriggerCondition
Information


Creates a new operation thread

Creates a new operation thread

Tested


Increases the TriggerExecutionCount

Increases the TriggerEvaluationCount

Tested


Will be destroyed with TriggerRemoveAction

Will be destroyed with TriggerRemoveCondition

Tested


Will not be destroyed if trigger is destroyed.

Will be destroyed if trigger is destroyed.



TriggerExecute is 25% slower ...

... than TriggerEvaluate.



TriggerSleepAction works.

TriggerSleepAction crashes the thread.

Tested



Corruption of IDStack: Click me

IDStack Corruption only matters for TriggerActions because TriggerSleepAction() is needed for it. In TriggerConditions the thread would just crash.
What is tested is that the combination with trigger destruction + sleep action(s) + handle creation, is not a good idea.
The newly creatded handles can receive the exact same HandleId from allocation which is obviously a bug.
The exact test information can be read in linked thread. However if someone found out something helpful through
his own tests, then you're more than welcome to share it as this topic is still not completly clear.

===

The "ConditionalExecute" itself is not very important, not sure why it should determine something relevant. It does matter if TriggerEval or TriggerExec is called in the end, or both.
 
Last edited:
Level 8
Joined
Jul 10, 2008
Messages
353
@IcemanBo

I see, good info.

Does ConditionalTriggerExecute call TriggerExecute even if you dont have actions added to the trigger?

ConditionalTriggerExecute with no actions added just conditions, is it faster or same with TriggerEvaluate ?

Are there any comparisons done for ConditionalTriggerExecute, or its just the same as TriggerExecute?
 
Last edited:
Iirc it looks like

If TriggerEvaluate() then
--- TriggerExecute()
Endif

(?)

^If simply "ConditionalTriggerExecute" is fired, then no new operation thread has started by its own. But then:

TiggerEval (always) fires:
-> Condition is fired -> New operation thread

If TriggerEval returned true:
-> Action is fired -> New operation thread

Does ConditionalTriggerExecute call TriggerExecute even if you dont have actions added to the trigger?
Yes, if Eval() returned true.

ConditionalTriggerExecute with no actions added just conditions, is it faster or same with TriggerEvaluate ?
It is slower, because you have one middle function to call, "ConditionalTriggerExecute", instead of directly evaluating the trigger, + 1 If-statement + 1 potential TriggerExecute().

Are there any comparisons done for ConditionalTriggerExecute, or its just the same as TriggerExecute?
I guess it's covered for now already (?).
 
Level 8
Joined
Jul 10, 2008
Messages
353
@IcemanBo

a trigger like

JASS:
function InitTrig_Example takes nothing returns nothing
   set trig = CreateTrigger()
   call TriggerAddCondition(trig, Condition(function xxx))
   call TriggerAddAction(trig, function yyy)
endfunction

What will happen if i call it with TriggerExecute() vs ConditionalTriggerExecute() ?

TriggerExecute does not check the condition?
Also is paused by TSA

ConditionalTriggerExecute() Check ONLY the condition or checks condition and then the action?
Paused by TSA ?
 
Level 8
Joined
Jul 10, 2008
Messages
353
Execute will fire the action, but not the condition. For the action a new operation thread is created.

As written:
TriggerEval() -> Condition will run
TriggerExec() -> Action will run

How i execute a trigger with condition and action then? I mean when i want action to run if the condition is correct.
 
Level 8
Joined
Jul 10, 2008
Messages
353
you said ConditionalTriggerExecute will triggerevaluate and then TriggerExecute. So I guess for my example trigger, ConditionalTriggerExecute is needed cause I need to TriggerEvaluate and then TriggerExecute
 
Iirc it looks like

If TriggerEvaluate() then
--- TriggerExecute()
Endif

(?)

^If simply "ConditionalTriggerExecute" is fired, then no new operation thread has started by its own. But then:

TiggerEval (always) fires:
-> Condition is fired -> New operation thread

If TriggerEval returned true:
-> Action is fired -> New operation thread
TriggerExecute will only get fired if TriggerEvaluate() returned true. If the condition won't match, then the actions will never fire.
 
Level 8
Joined
Jul 10, 2008
Messages
353
If TriggerEvaluate() then
--- TriggerExecute()
Endif

The above was referred to ConditionalTriggerExecute() correct ? If thats the case then its clear for me now
 
Level 8
Joined
Jul 10, 2008
Messages
353
I will. If thats the case the initial comparison for ConditionalTriggerExecute() with no actions and TriggerEvaluate() would mean that TriggerEvaluate is faster due to the less code sort of. Practically its same.

As ConditionalTriggerExecute() with no actions would look like this:

if TriggerEvaluate() then
endif

vs

TriggerEvaluate()
 
If an actions exists or not has no effect on if "TriggerExecute()" is fired. It will be always fired if "TriggerEvaluate()" returns true in "ConditionalTriggerExecute()".

But if you explicitly don't need to fire conditions AND actions (if conditions is true) then it never makes sense to to use ConditionalTriggerExecute(), but only TriggerEval or TriggerExec respectivly.

Do you have a specific use case problematic, or just theory?
 
Status
Not open for further replies.
Top