• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Wait and Wait (Game-Time)

Status
Not open for further replies.

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
What are the different between Wait and Wait (Game-Time)? Example would be helpful as well.
Wait calls this...
JASS:
native TriggerSleepAction takes real timeout returns nothing

Wait (Game-Time) calls this...
JASS:
function PolledWait takes real duration returns nothing
    local timer t
    local real  timeRemaining
    if (duration > 0) then
        set t = CreateTimer()
        call TimerStart(t, duration, false, null)
        loop
            set timeRemaining = TimerGetRemaining(t)
            exitwhen timeRemaining <= 0
            if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
                call TriggerSleepAction(0.1 * timeRemaining)
            else
                call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
            endif
        endloop
        call DestroyTimer(t)
    endif
endfunction

Both use the same TriggerSleepAction to suspend the thread for a period. PolledWait uses a timer to keep timing accuracy so performs better with long delays. Both perform as badly with short delays due to the mechanics of TriggerSleepAction. PolledWait also leaks a handle index do to a JASS bug.
 
Level 2
Joined
May 18, 2013
Messages
9
In reality you should never use Wait (Game-Time) due to the leak. You can use a custom function designed like PolledWait but with the leak fixed.

For very accurate timing, use a timer.

Thanks a million Doc. That sure did clear up a lot and I shall grant you a beautiful rep :grin:

@MasterTrainer: I am still new to this. I haven’t explored with countdown timer yet, just was puzzle by wait and wait (game time).
 
Last edited:
Status
Not open for further replies.
Top