• 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.

TriggerSleepAction vs. PolledWait

Status
Not open for further replies.
Level 9
Joined
Nov 4, 2007
Messages
933
In my experience of using Wait actions in a trigger, these are the most common I have seen in other people's maps, but the only one that seems reasonable to use is the TriggerSleepAction one because the PolledWait is said that it can last slighty longer than expceted, so why do some triggers use PolledWait instead of the other is my question, I just don't understand the purpose of it.
 
Level 11
Joined
Feb 22, 2006
Messages
752
I try to avoid those sleep functions as much as possible and just use recycled timers. I've never used PolledWait() in my life but I know TriggerSleepAction() has a minimum wait time somewhere around 0.1-0.5 seconds (it sleeps a thread, so the amount it time it takes to actually sleep the thread depends on the system).
 
Level 9
Joined
Nov 4, 2007
Messages
933
Recycled timers? I apologize for asking, but I want to know how exactly does a recycled timer pause actions as opposed to the polled and sleep actions, I'm very intrigued.
 
Level 11
Joined
Feb 22, 2006
Messages
752
If you want to sleep a thread occasionally for >1 second, just use TriggerSleepAction (or PolledWait) because as long as you store event response info in local variables (since every event response function except GetTriggerUnit() breaks after waits), they work just fine.

I use recycled timers when I want to have extremely short waits, like 0.03-0.05 seconds. When I want to start the wait, I get a timer and call TimerStart() on it with the timeout set as the period of time I want to wait. Then when the callback function executes I do whatever I want to do after the wait. The only drawback to this is that the callback function executes in a new thread and there's no way to directly pass local variables to that function, but I use vJass so I don't really have to worry about that.
 
Status
Not open for further replies.
Top