06-12-2012 03:47 PM
Hiya Gurus,
I'm trying to get familiar with queues. Under what circumstance would you enter a name for a queue when you create it? What benefits would that give you?
Thanks!
Solved! Go to Solution.
06-12-2012 03:50 PM
I always give my queues names. You can use them if you are running multiple queues and want to send messages to different queues, like for example, one queue for each spawned process.
06-12-2012 03:52 PM
06-12-2012 03:53 PM
When you name a queue, you can obtain the queue by name elsewhere without having to bring in the wire.
Unless there's a good reason to do that, however, I'd stay away from it and just treat the queue as a reference bringing it down into SubVIs the same way.
06-12-2012 04:02 PM
All these answers make sense. Thanks. I've been creating local variables of the output of the "Obtain Queue" function and using them, instead of wiring the queue directly. Is there anything inherently wrong with this approach? I suppose it could cause some timing conflicts.
06-12-2012 04:10 PM - edited 06-12-2012 04:11 PM
Remember, if you obtain a queue by name it creates a NEW REFERENCE for each instance that you obtain for that particular queue! If you just split the wire, it makes a copy of the same reference. So, when done using the references you obtain using a named queue, make sure you close all of them (or set force destroy to true on the release queue VI).
06-12-2012 04:24 PM
So I used the "Obtain Queue" function and named the queue "Test." When I use the "Enqueue Element" function somewhere else in the VI, how do I reference the queue named "Test" to let the "Enqueue Element" function know which queue I am looking for? There is no input for "Queue Name" or anything like that.
Sorry to be so thick here. Thanks again.
06-12-2012 04:27 PM
You have to use the "obtain queue function" again and wire up the name, then use the enqueue function to that queue reference, then close the new queue reference that you just opened.
06-12-2012 04:30 PM
You call the "Obtain Queue" again and give it the name "Test". There is an output of the "Obtain Queue" function that indicates if it created a new queue. Then take the queue out of the obtain queue and wire it to your "Enqueue Element". Please note the warning from the post above yours: "Remember, if you obtain a queue by name it creates a NEW REFERENCE for each instance that you obtain for that particular queue! If you just split the wire, it makes a copy of the same reference. So, when done using the references you obtain using a named queue, make sure you close all of them (or set force destroy to true on the release queue VI)."
Charles Chickering
06-12-2012 04:30 PM
@for(imstuck) wrote:
You have to use the "obtain queue function" again and wire up the name, then use the enqueue function to that queue reference, then close the new queue reference that you just opened.
It probably goes without saying, but if you're in the same VI you can use the original queue wire.