How to Extract All Elements From a Queue

Updated Aug 21, 2023

Reported In

Software

  • LabVIEW

Issue Details

I am using a Producer/Consumer design pattern to acquire and save data in separate loops. I am using Dequeue Element function to remove each element from my queue to then save to a file.

However, my consumer loops can't keep up with the speed I am acquiring the data and queue gets filled up. How can I read all the data points in the queue in one go, in order to save the data quicker. 

Solution

This issue occurs when you are acquiring data faster than you can process the data. To process the data faster instead of using the Dequeue Element function use the Flush Queue function to remove all the elements currently in the queue at once. 

The Flush Queue function returns all the elements in the queue as an array. This array can then be saved in one go to your file. This process is a lot faster than trying to save each individual data point one at a time.