This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

What Is a Queue?

Updated Mar 5, 2019

Reported In

Software

  • LabVIEW

Issue Details

  • It has been suggested to me that I should use a queue in my code. What is a queue and how do I use it?
  • How can I pass data from one loop into another loop running in parallel?

Solution

A queue maintains a first in/first out (FIFO) order of data items. For instance, the customers waiting in line at a fast food restaurant are in a queue. The first customer to arrive is going to be the first one served.

A queue is useful in producer/consumer situations, where one portion of code is creating data to be used by another portion. These can e.g. be two loops running in parallel. The advantage of using a queue is that the producer and consumer rates do not have to be identical. If consumption is slower than production, the queue will eventually become full and the producer code will be forced to wait until the consumer has dequeued an element before a new element can be queued up.

Figure 1: The VIs on the Queue palette (Programming » Synchronization » Queue Operations)

Additional Information

Unlike an array, it is not possible to randomly access elements in a queue. It is strictly a buffer that provides you the ability to enqueue (add/insert) and dequeue (subtract/remove) elements. The only way to view all the elements in a queue is to dequeue them one by one. You cannot perform data manipulation to all the elements in a queue either.

Look for example programs in the LabVIEW shipping examples. Open the LabVIEW Example Finder by selecting Help » Find Examples and then search for Queue in the search tab.

For information on other types of data transfer, see Data Communication Methods in LabVIEW - LabVIEW 2018 Help.

WAS THIS ARTICLE HELPFUL?

Not Helpful