08-08-2019 09:16 AM - edited 08-08-2019 09:16 AM
Wait (ms) doesn't accurately wait, so if you're using this for software timing it's not the best.
I always use the newer High Resolution Polling Wait function: https://zone.ni.com/reference/en-XX/help/371361R-01/glang/high_resolution_polling_wait/
Yea, it's not a VIM and can't be inserted on any wire, but it has standard error functionality, and won't wait if an error is on the wire. It also waits the actual amount of time you requested 🙂
I'd rather have the stall function use this wait under the hood, rather than the inferior Wait (ms).
Here's how I would wrap this into a VIM, so it works as it should:
See attached 🙂
08-08-2019 10:43 AM
@Craig_ wrote:
I'd rather have the stall function use this wait under the hood, rather than the inferior Wait (ms).
The flipside is the High Resolution Polling Wait function polls a timer. Doing that everywhere will drain your CPU, and defy the purpose of the 'exact' wait as it does.
It's definitely not superior, at least not in general. It just has an entirely different purpose than the normal wait (ms), with it's own ups and downs. IMHO.
Here's how to drain my 4 CPUs, ironically the waits usually are there to prevent that:
08-08-2019 11:11 AM
Yes, the polling wait is implemented with a poll, and yes that can thrash the CPU, but it accurately waits!
At higher waits it uses the Wait (ms) for a large chunk of the time, and then polls to get an accurate finishing time.
In my use cases, I'm using the wait to add intentional delay between operations, and having that be relatively accurate is very useful. I don't use it as a loop timer.
If you want to yield the CPU and know that that the Wait (ms) value you specify has varying accuracy depending on operating system, then that function is perfectly applicable.
08-08-2019 12:25 PM
When the High Resolution Polling Wait.vi was proposed, my response was, "Sweet! I'm going to use this everywhere I used to use Wait (ms), since it has error terminals." To which the authors of the VI responded, "NO! You should only use this VI if you actually *need* the high resolution!". At which point they stuck a red exclamation mark on its icon and added the phrase "Use this VI with caution" to its context help.
So I'm on the Stall Data Flow.vim train now, and I hope the idea linked above gets more kudos.