07-24-2013 10:18 PM
@crossrulz wrote:
RandelPrandel wrote:
I was wondering if you could explain or point out to some reading material which explains the advantages of feeding an empty array to the queue. The reason i ask this is because i don't see any apparent data loss. Is it explicitly used to eradicate data loss?
I don't know about any reading material. I just learned that lesson by experience.
Let's just say the the producer loop iterates twice as fast as the consumer. So for every iteration of the consumer loop, there's an additional element in the queue. Just to keep it simple, let's say you press the stop button in time for the 10th iteration of the consumer loop to read the button press. So when the consumer loop quits, you still have 10 elements left in the queue that will never get processed. Data loss.
So you really should not stop the consumer loop on the button press. You need a command in the queue to let the consumer loop it has processed all of the data. My way of doing that is to send an empty array when the producer loop is complete. So when the consumer loop dequeues an empty array, I stop the consumer loop. Only then can I destroy the queue.
Look into the help file for "Enqueue Opposite End" Also check out the Project template "Contineous Measurment and Logging" Look into the "Priority Queue.vi" and the actor framework.
Producers "Command" at the front of a queue, Consumers "Message to self" at the back end of a queue. Command responses SHOULD "Flush Queue" as required to throw out superceded directions.
Don't hate me Stephen, I still don't think "stop on error out" of dequeue is sound TEST. (it may be sound SE)
08-05-2013 04:44 PM - edited 08-05-2013 04:44 PM
Thanks Jeff and Crossrulz.