LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
James_McN

DVR Read Primitive

Status: New

DVRs have the potential to be a great way of sharing data by reference and the in place element structure is a great way to protect against race conditions however sometimes I still want to only read the value.

 

Right now you still have to use the IPE which takes up a lot of diagram space. It would be great to have a read primitive for this situation.

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
1 Comment
AristosQueue (NI)
NI Employee (retired)

Just a read would require duplicating the data in the DVR if you did it without the structure node. If you have a special case data type, like a DVR of an integer, create a subVI around the IPE. That's valid for the simple types. But in the general case, DVRs are used with largish clusters and arrays. "Just a read" for these generally means you want to get a value out of them. Use the IPE to get the cluster, then copy out just the one variable that you want from the array/cluster, and put the rest back in the DVR. Even when you "just want to read" something like a string, you often use that string for some read-only operation, like using it to select a case frame. If you can put the case structure also inside the DVR, that cuts down on the memory copy.

 

I can say with fair certainty that we won't be providing a standalone "read" primitive. Many users who do not understand the implications of the structure node can -- and do -- write highly efficient programs because that's the only node they have for reading the DVR. They'll pick the Read DVR node, if it were available, every time for situations where it is entirely inappropriate just because it takes less space. It is way too subtle to ask all programmers to keep track of the fine details of DVR memory copies. I certainly don't want to think about it, so I use the structure node and I'm happy about it. It is the right tool for the job. Don't think of the IPE border nodes as a "read DVR" and "write DVR" pair. Instead think of it as a "lock value" and "unlock value". Even when you're doing read-only type operations, you often want to maintain that lock for the duration of the read.