![]() |
How To use Global variables and sequences
Whats the proper way to use global variables? I've used quite a few in my project to pass variables between subvi's. In another thread, (here), Greg said "you will get burned by parallel updates or race conditions."
I made sure I'm only writing the variables in one place. So I think I'm ok with the parallel updates. I don't think I'd have an issue with a race condition. But if I did, how should it be handled? |
Re: How To use Global variables and sequences
It is all about using the right tool for the right job. Are you sure you want a global? Would a queue, a notifier or a user event work better for your application?
User events notifiers and queues can be passed around to subVIs, which makes code re-use easier later. A queue allows you to guarantee that you will get all the data across, but is typically one write/one read. A notifier only pushes data when you are ready to read it - if the listener is busy, it (intenionally) drops the write on the floor. A user event is one write/multi read, but harder to use. A global is easy to use, but doesn't have some of the extra features of the other options. Also, always lump related data together - if you use something as a cluster, make it a cluster. This will ensure that the entire kit'n'kaboodle gets written simultaneously, and will prevent you from reading half new and half old data. |
Re: How To use Global variables and sequences
Quote:
|
| All times are GMT -5. The time now is 09:25. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi