LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Waiting on any of multiple queues to have data

 


@InfiniteNothing wrote:

I'm looking to execute when either gets data. The rendezvous is the opposite of what I want I think.

 

The problem with timeouts is the queues are fed at different rates. While one queue is waiting, the other will stack up messages and I'd have to write a "catch up" mechanism for it. It seems inelegant. Using variants seems inefficient (because of packing and unpacking) and a little inelegant. Maybe just cluster all the types together (in my example the array and the integer) along with a flag of which part of the cluster has valid data. It still seems inelegant. There's also a bit of a problem if the producers are enqueuing lossily. Then the faster data source gets priority over which producer gets more samples in the pipe.

 


Timeouts can work but it does turn the process doing the dequeue into more of a polling process. If you have a single section of code that invokes both dequeues at the same time using the same timeout (something realtively small, perhaps even 0) you have effectively checked the status of both queues and can take the appropriate action. I would imagine that the data for the queues would either have a shift register or some default value that you would use if one of the queues did timeout. I say this because your are using the output of both queues in a single calculation in the example you posted.
You could still use a single queue approach if the data is independent of each other. If used in a single calculation you would need some mechanism for passing default/previous data when nothing was present on one of the queues.

 



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 11 of 13
(411 Views)

Have you considered using User Events instead of queues?  You get the advantages of both multiple queues (by using different user events) and a single queue (all the events feed into the same event queue).

0 Kudos
Message 12 of 13
(396 Views)

I would use User Events instead of queues.  They are not as fast, but they will do exactly what you want.  Create two user events with the data you want.  Instead of filling queues for the data values, fire user events.  In your event loop, use a shift register to keep track of the last value for each of the values.  At each event, do the math and display.

0 Kudos
Message 13 of 13
(375 Views)