LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For communication between loops, more queues, or less queues, which better?

Hello  everyone!

I have been recently learnning about communications among threads and The Actor Framework. An easy question come up: think of a simple model-----a producer loop and a consumer loop. Datas are transmitted from producer to consumer and there are three data-types:

1. enumeration, which lists all possible messages told by the producer to that consumer.

2. such like a long waveform or a large matrix usually, big data needed by the consumer.

3. an indicator telling consumer that whether the transmitting message is valid or not.

And the case is: a big subset of all possible messages are not needed to carry data, only a small subset of messages are transmitted with data and the 3rd type "indicator" is optional.

So one may use two or three queues(enum-queue, data-queue, optional indicator-queue) or may use one queue(cluster-queue, the three data-types are bundling).

I wonder how to choose the style, which is better? especially when it comes to performance or maintance?

Thanks!

0 Kudos
Message 1 of 5
(3,693 Views)

Wow.  I have no idea what you are talking about!  Maybe a code example so we understand the three Data Types?

 

Bob Schor

0 Kudos
Message 2 of 5
(3,629 Views)

One queue.  Absolutely and definitely.  Else how could you possibly know how to correlate "message", "data", and "validity"?    Which data goes with which message?  Which validity flag corresponds to which data?

 

But keep them together in a cluster (a *typedef'ed* cluster, BTW), there can be no doubt how to correlate them.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 3 of 5
(3,514 Views)

@Bob_Schor  已写:

Wow.  I have no idea what you are talking about!  Maybe a code example so we understand the three Data Types?

 

Bob Schor


Sorry I didn't make myself clearly and I agree that an example code will bring convenience.

The answer I wonder is  which style is better.

case-A.pngcase-B.png

0 Kudos
Message 4 of 5
(3,413 Views)

Bundle the data types.  1 Queue.

 

The problem with 3 different queues is that the loop won't iterate until there is in element in each of the queues.  If one queue gets more elements than the others, then that queue will fill up with data since it can't dequeue something until all queues get an item and the loop rolls around again.

 

Also, as others have said, individual queues means there isn't any real relationship between the queues, while when you bundle the data, you know the 3 data elements belong together when you dequeue them, because you put them in the queue together!

0 Kudos
Message 5 of 5
(3,387 Views)