To download NI software, including the products shown below, visit ni.com/downloads.
Overview
Using queues in a single producer/consumer architecture is easy to implement with lots of example code available off the community. What we will look at here is another way of dequeuing data out of a queue
Description
Geneally the queue functions can be referenced to each other by simply connecting the "Queue in" and "Queue out" terminals of the function. This is very straight forward and the fastest way to do it if queues are to be enqueued and dequeued in the same VI. But how do you connect these terminals if you are to dequeue elements from a queue in another VI? Or in multiple VIs?
An amazing feature about queues is that they can be given unique names which can be used as references when obtaining the queue. The following example produces random data in two seperate VIs (Producer1 VI & Producer2 VI), each getting stored in separate queues. These queues have associated names to them and are then called in a third VI to dequeue each of the respective queues.
It is important to note that no Ref Nums have been used to locate the queues. This approach can be used in SubVIs or even different VIs altogether. It does not neccesarily need to be a subVI
Requirement
Steps to Implement or Execute Code
Additional Information or References
Block Diagram
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Make sure you are closing those references, otherwise this could turn into a very interesting memory leak.
Personally, I find it best to use an Action Engine to hold your queue references. The consumer should create the queue and be the only place that dequeues. Other VIs can just use the Action Engine to enqueue data.