The Producer/Consumer design consists of parallel loops which are broken down into two categories; producers, and consumers. Communication between producer and consumer loops is done by using queues or channel wires.
LabVIEW has built-in Queue Operation VIs found in the Functions palette >> Data Communication >> Queue Operations.
Queues are based on the first-in/first-out theory. In the Producer/Consumer design pattern, queues can be initialized outside both the producer and consumer loops. Because the producer loop produces data for the consumer loop, it will be adding data to the queue (adding data to a queue is called “enqueue”).
The consumer loop will be removing data from that queue (removing data from a queue is called “dequeue”). Because queues are first-in/first-out, the data will always be analyzed by the consumer in the same order as they were placed into the queue by the producer. Figure 1 illustrates how the Producer/Consumer design pattern can be created in LabVIEW.
Figure 1: Producer/Consumer Design Pattern
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.
There are examples for using queues within LabVIEW which you can use as a starting point for your application. Find examples using the LabVIEW Example Finder and search for Queue.
Channel wire functionality was added in LabVIEW 2016. You can use channel wires to achieve the same functionality as queues.
In queues, you set up the queue reference (Obtain Queue), add data (Enqueue) and remove data (Dequeue), and close the queue reference (Release Queue); with Channels, this process is simplified to only set up the Writer and Reader of the data.
For more information on channel wires and getting started templates, see Communicating Data between Parallel Sections of Code Using Channel Wires – LabVIEW Help