04-29-2010 06:07 AM
04-29-2010 07:26 AM
F. Schubert wrote:[...]
But I must confess, that I really do use those evil globals to pass data around.
[...]
That's OK Felix, you have over 2 years experience.
04-29-2010 07:53 AM
Some more ideas come to my mind.
a) using private properties, we could write some tool that is verfying that there is a single writer to each global. Maybe a good place would be a prebuild hook in the AppBuilder so you verify it for all dynamically loaded vi's as well.
b) using scripting, we might actually write a converter that is replacing all globals with LV2style globals. That way we (with the min 2 years experience) could mess around with globals for the easy use and when the co-worker that is not yet global-proof comes, we automagically convert them all before he sees them...
Felix
04-29-2010 08:00 AM
F. Schubert wrote:
a) using private properties, we could write some tool that is verfying that there is a single writer to each global. Maybe a good place would be a prebuild hook in the AppBuilder so you verify it for all dynamically loaded vi's as well.Dynamic VIs are not necessarily available at build time, thus making this feature incomplete.
b) using scripting, we might actually write a converter that is replacing all globals with LV2style globals.
If a LV2 global only has read-write functionality, it's not any better than a global.
04-29-2010 09:16 AM
jcarmody wrote:
Does this sound like an application for a Singleton? I've never tried one before, but I did sleep at a Holiday Inn last night.
A SEQ without the "Dequeue" option would be enough. Only able to get the data via "Preview" (thus not removing it from the Queue) and Bob's your uncle. And I should know, I have an uncle called Bob.
Shane.
04-29-2010 09:48 AM
Intaris wrote:A SEQ without the "Dequeue" option would be enough.
You mean like a notifier?
The notifier has an additional advantage in that if you want, you can have each place in the code read a new value only once.
04-29-2010 10:09 AM
Yeah it could be a notifier also, but then you'd have to block access to the "Send Notification" function to prohibit writes. But then how to initialise the notifier?
Blocking a dequeue will automatically prevent writes on a SEQ (timeout on subsequent attempted writes).
Shane.
04-29-2010 10:27 AM
Ben wrote:
Intaris wrote:Isn't this kind of easy to do with LVOOP?
A write function which allows only a single execution, otherwise returning an error?
Shane
I don't remeber which thread I posted this image too but YES!
Ben
A zip of that code ( a LV constant based on LVOOP) can be found in this thread.
Ben
04-29-2010 10:33 AM
tst wrote:If a LV2 global only has read-write functionality, it's not any better than a global.
Reminds me of this. (message 35 and 36).
04-29-2010 11:20 AM
Intaris wrote:Yeah it could be a notifier also, but then you'd have to block access to the "Send Notification" function to prohibit writes.
Fair enough, although IMO, code which has fake multiple writes is much worse than code which has real multiple writes. The only way this will be acceptable is if the enqueue VI raises a clear error whenever its timeout output returns T (meaning the queue is full).