mike5 Posted March 5, 2010 Report Share Posted March 5, 2010 What's the best way to access the same object from parallel loops? And I mean THE same object not copies of the same object, because so far this is the only thing I've achieved, so updates from one loop do not make it into the other. Thanks in advance, Mike Quote Link to comment
jgcode Posted March 5, 2010 Report Share Posted March 5, 2010 What's the best way to access the same object from parallel loops? And I mean THE same object not copies of the same object, because so far this is the only thing I've achieved, so updates from one loop do not make it into the other. Thanks in advance, Mike Hi Mike You have a bunch of options to create by reference (ByRef) objects all with their pros and cons, here are some... Use LVOOP with Data Value References and the In Place Element (IPE) (new in 2009) Create a Single Element Queue (SEQ) and create your own ByRef API Use a third party tool such as Endevo GOOP, Sciware etc... Quote Link to comment
Aristos Queue Posted March 5, 2010 Report Share Posted March 5, 2010 What's the best way to access the same object from parallel loops? And I mean THE same object not copies of the same object, because so far this is the only thing I've achieved, so updates from one loop do not make it into the other. What is the best way to access the same array from parallel loops? Whatever answer you give here, use the same mechanism for objects. Quote Link to comment
crelf Posted March 5, 2010 Report Share Posted March 5, 2010 LVOOP is by-value, just like almost everything else in LabVIEW, so don't think of it like "how do I access objects across parallel loops", instead think of it as "how do I acess <anything> across parallel loops". LVOOP is by-value, just like almost everything else in LabVIEW, so don't think of it like "how do I access objects across parallel loops", instead think of it as "how do I acess <anything> across parallel loops". ...just noticed that Aristos already answered the question better than me Quote Link to comment
Daklu Posted March 5, 2010 Report Share Posted March 5, 2010 (edited) What's the best way to access the same object from parallel loops? And I mean THE same object not copies of the same object, because so far this is the only thing I've achieved, so updates from one loop do not make it into the other. I agree with everything previously said in this thread, so let me add something a little different. You are asking the wrong question. Instead of "how do I access the same object in parallel loops," you need to ask "how do I want this class to behave?" Broadly speaking, there are three possibilities: By-val. Each new instance creates a new object. Branches create a copy of the object. (This is the "normal" way.) By-ref. Each new instance creates a new object. Branches refer to the same object. Singleton. All instances and branches refer to the same object. (You can create classes in which some data is by-val, some is by-ref, and some is singleton, but that's beyond the scope of this post.) By first defining the expected behavior for the class as a whole, you can build that functionality into the class itself in a way that doesn't break your application in other areas. If the class' built-in behavior doesn't fit your requirements at a certain point in the code, you add other code at the application level to fit the behavior you need there. Suppose your program will have lots of instances of a class, so you decide it should be by-val to simplify the programming. But in this one place you need by-ref behavior so you can access the object from parallel loops. That's where you would use the DVR or other techniques to enable that functionality. On the other hand, if it makes sense for the class itself to be by-ref, you can build that into the class members in a way that class users don't have to worry about DVR's, IPE's, queues, FG's, etc. The class user just needs to know that it's a by-ref object, and branches don't create copies. [Edit - Changing an object's behavior can only be done in a single direction. (By-val -> By-ref -> Singleton) You can make a by-val object behave like a singleton, but you can't make a singleton behave like a by-val object.] Edited March 5, 2010 by Daklu 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.