LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Facing delay issue while sending stream of data from one producer loop to multiple consumer loop using queues

Solved!
Go to solution

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.

0 Kudos
Message 1 of 6
(1,448 Views)
Solution
Accepted by topic author msabah38

@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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 6
(1,425 Views)

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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 6
(1,423 Views)

What would be the best way to transfer a continuous stream of data from one producer to many consumer loop.

0 Kudos
Message 4 of 6
(1,415 Views)

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

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 5 of 6
(1,387 Views)

@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!

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 6
(1,358 Views)