LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When Do You Name a Queue?

Solved!
Go to solution

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!

 

 

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
Message 1 of 27
(8,656 Views)

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.

-------
Mark Ramsdale
-------
0 Kudos
Message 2 of 27
(8,653 Views)
Solution
Accepted by diarmaede

As an example, you can use this name  with Obtain Queue in a subVI to enqueue element in the main VI.  The detailed help of the Obtain Queue function will give more informations.

 

Ben64

Message 3 of 27
(8,650 Views)

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.

Message 4 of 27
(8,649 Views)

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.

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 5 of 27
(8,640 Views)

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).

Message 6 of 27
(8,634 Views)

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.

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 7 of 27
(8,628 Views)

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.

Message 8 of 27
(8,621 Views)

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

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 9 of 27
(8,615 Views)

@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.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 10 of 27
(8,616 Views)