HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

PolledWait vs TriggerSleepAction, which one is realy better?

09-09-2006, 01:41 AM#1
grupoapunte
Hi, since i started Programing in JASS i found many places where it is said that PolledWait() is better than TriggerSleepAction(), after looking at PolledWait i found that it leaks since it does not nullify the timer, i been using this function in my hero revival trigger and i realy don't know how bad can it be since players die a lot, so after a while it may add some lagg, and im starting to think that a TriggerSleepAction would be better to wait until the hero death timer ends.

So whats the best way to do things, why is that TriggerSleepAction() isnt good for some programmers?

Thanks.
09-09-2006, 02:02 AM#2
Rising_Dusk
TriggerSleepAction()s as well as PolledWait()s are innaccurate to say the least.
They are never quite as long as the duration you set them at.

Most people prefer timers for things where accuracy matters, and prefer TriggerSleeps when accuracy is not an issue.
In any case, I think timers are smarter than both PolledWait and TriggerSleep.

In contrast between TriggerSleep and PolledWait, since PW uses a timer in it is refers to 'gametime' mostly.
Whereas since TriggerSleep does not, it can be even more innaccurate since it's classified as in a way 'real time'.
09-09-2006, 02:49 AM#3
aquilla
The difference pretty much is that PolledWait stops if the game is paused etc as it uses a timer. It isn't more accurate though, possibly less accurate (especially on low values). And the function is pretty lame, and even leaks as you mentioned. I tend to just use sleep or a timer (and attach values :/) but if you prefer PolledWait you could always make a new function and clean it up a bit...
09-09-2006, 03:07 AM#4
Vexorian
both are inacurate. But timers have their own flaws, for example you need to use an attach system to pass values to them and then have to deal with the risk of bugs, or use a wrapping function which is kind of annoying
09-09-2006, 08:22 AM#5
Captain Griffen
PolledWait is considerably more accurate. TriggerSleepAction will be somewhere between 0.5 to 2 times as long as it should be, and no way you can tell, while PolledWait will be around 0.3 seconds too much each time, but won't be off by much. The leak is minimal, and is fixed by Vex's optimiser. Alternatively, you could make your own function, which does a similar thing but more accurately and efficiently, and leaklessly.

If you want real accuracy, you'll have to use timers, which cannot have values passed to them without an attach system, or using the TimerAttach functions I made (which is easier, as they don't require any setup, but can only attach one integer). Personally, I'd go for Karukef's SmartTimers, as the pool of timers will be faster, and also avoid timer's rather random bugs.

Quote:
TriggerSleepAction()s as well as PolledWait()s are innaccurate to say the least.
They are never quite as long as the duration you set them at.

PolledWait will ALWAYS go for at least as long as the duration.