LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Questions regarding queue's and enqueueing a cluster

Solved!
Go to solution

I'm looking for some information about queue's and memory usage that I don't fully understand.

 

If you use a queue in a state machine, producer/consumer style VI with a cluster that gets enqueued in the state machine and dequeued in a consumer loop, does the queue hold data after it has been dequeued, or does it "flush itself" of that dequeued data so it is ready to have more data enqueued? 

 

Example: If I enqueue data points (doubles) 1, 2, 3, 4, 5 in a cluster, they get dequeued in the consumer loop in order 1,2,3,4,5. When I enqueue the next data, say 6, 7, 8, 9, 10 is it now only those new 5 data points in the queue because I dequeued 1,2,3,4,5 or am I still holding onto 1,2,3,4,5 and now adding 6, 7, 8, 9, 10, so my whole queue is 1,2,3,4,5,6,7,8,9,10 ?  Does a queue empty itself upon dequeuing? Because I don't want to accidently build this giant queue that is keeping all the data that has ever been enqueued while the VI is running.

 

I apologize if I'm not articulating this well.

0 Kudos
Message 1 of 4
(210 Views)
Solution
Accepted by topic author Nadweb

Yes, when you dequeue an element it's taken off the queue for good. You can "inspect queue" if you want to see what is on the queue without taking elements off, but I don't think I've ever used that in an application.

Message 2 of 4
(203 Views)

Thanks for that info Gregory!

 

That's sort of what I thought, but I just wasn't exactly sure, especially when I saw the Flush Queue Function. I thought maybe you had to "manually" do it by using this function.

0 Kudos
Message 3 of 4
(194 Views)

Actually, I do have a specific use case where I inspect a queue and pull the array of elelments out. If I am keeping a a list of the last X events/data points/whatever, I will use a fixed size queue of size X and use the Lossy Enqueue to add the latest element. This is a quick and easy way to get a circular buffer. The elements preserve the order that they were enqueued and I don't have to keep track of an insert index if I were to do this myself using an array.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 4
(137 Views)