LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dequeue question

I think I'm misunderstanding something basic about the Dequeue function.  The Labview help for Dequeue states that "if queue becomes invalid (for example, the queue reference is released), the function stops waiting and returns error code 1122".  I've attached a sample VI where one loop adds data to a queue and when the user hits stop releases the queue.  A second loop dequeues the data (with no timeout) until there is an error.  My understanding was that the releasing the queue should cause an error and thus end this loop, but when I run this Dequeue never returns.  Why is this?
 
 
0 Kudos
Message 1 of 5
(3,099 Views)
Instead of creating 2 queues with the same name, just wire the same queue to both while loops. I'm not sure why your way doesn't work, there should only be one queue if you name them the same. Although there are now 2 references, so releasing one might only release the reference and the queue will remain until all references are released. I'm not sure about that, but it seems like what's happening here.
Message 2 of 5
(3,084 Views)

The Help is correct, it just fails to mention the different ways Queues work.

In the example you posted, you are opening two references to the same Queue by using the Name terminal on the Obtain Queue function. If you look at the Release Queue function, there is a terminal named "force destroy? (f). Since you opened two references to a single queue, you need to close each of those references for the Queue to be completely released from memory. You can do this by either using multiple Release Queue functions or by connecting a True Boolean constant to the force destroy terminal of a single Release Queue function.

Doing that will completely delete the queue and the Dequeue function will generate the error.

Ed



Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 3 of 5
(3,083 Views)

OK.  I think I'll use the force destroy option.  In my actual application I have the loops in separate VIs so I was roughly following the "Queue Messaging Logging" example in opening multiple references with the queue name.  Which brings me to a related question:  Are there pro/cons to passing the actual queue reference to subVIs as opposed to passing the Queue name and obtaining a new reference?  Thanks.

Paul

0 Kudos
Message 4 of 5
(3,080 Views)


@Phamton wrote:

Are there pro/cons to passing the actual queue reference to subVIs as opposed to passing the Queue name and obtaining a new reference?  Thanks.

Paul


Six of one, half dozen of the other.

Passing a single reference around means you only have a single reference to close, but getting a reference to an existing Queue by using names is usually easier. You just have to remember to close each reference individulally or use the Force Destroy option.

I normally use the Named Queues.

Ed



Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 5 of 5
(3,074 Views)