12-09-2020 11:51 PM - edited 12-09-2020 11:54 PM
I would to send continous stream of data from one while loop to three other while loop,
contionously without any delay.
I have tried using queues to send data from main while loop to other loop,
but it works perfectly fine if there is only producer- consumer loop (2 while loop),
it fails to work when we add one more consumer loop ( 3 while loop).
Kindly suggest where I am going wrong, or is there is a better way to send data from
one producer loop to two consumer loop.
Solved! Go to Solution.
12-10-2020 12:56 AM
@msabah38 wrote:
I would to send continous stream of data from one while loop to three other while loop,
contionously without any delay.I have tried using queues to send data from main while loop to other loop,
but it works perfectly fine if there is only producer- consumer loop (2 while loop),
it fails to work when we add one more consumer loop ( 3 while loop).Kindly suggest where I am going wrong, or is there is a better way to send data from
one producer loop to two consumer loop.
And therein lies your problem. Using queues is a many-to-one operation. You can have any amount of enqueues feeding one dequeue, but not the other way around. I believe this is in the manual. The most robust way to handle this situation is to actually create a queue for each consumer and enqueue the same data to each one.
12-10-2020 01:02 AM
More thorough troubleshooting would've revealed that what arrives at each dequeue will be random elements that, together, will equal the total data you enqueued.
Each dequeue will be in a race with the others to dequeue the element. The first one wins and grabs the data from the queue, all the others lose. The race is repeated every time a new element is enqueued.
12-10-2020 01:35 AM
What would be the best way to transfer a continuous stream of data from one producer to many consumer loop.
12-10-2020 07:26 AM
Do like billko already suggested in msg #2. Have a separate queue for each consumer and have your producer enqueue copies of the same data into all of them.
An alternative would be to go with User Events. Then you only push the data once into a single "Generate User Event" function. But behind the scenes, LabVIEW still does the same kind of data copying into separate event queues, one for each consumer that *registers* for the Event.
Unless my consumers were already set up to depend on Event Structures, I'd go with multiple queues and doing my own data copying.
-Kevin P
12-10-2020 06:40 PM
@Kevin_Price wrote:
Do like billko already suggested in msg #2. Have a separate queue for each consumer and have your producer enqueue copies of the same data into all of them.
An alternative would be to go with User Events. Then you only push the data once into a single "Generate User Event" function. But behind the scenes, LabVIEW still does the same kind of data copying into separate event queues, one for each consumer that *registers* for the Event.
Unless my consumers were already set up to depend on Event Structures, I'd go with multiple queues and doing my own data copying.
-Kevin P
I like user events as well!