LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

one producer two consumer loops, dequeue same element in both consumers

Solved!
Go to solution

Hi!

 

What is the best way for the following:

 

I enqueu data in my producer loop. I need this data dequeue-d in both of my consumer loops, but I want to dequeu the same element in both loops.

 

Of course if I put dequeues in both loop, then the second consumer loop will loose the odd elements and the first consumer loop will loose the even elements.

 

thanks!

 

0 Kudos
Message 1 of 10
(4,691 Views)
Solution
Accepted by topic author Blokk

Hi,

 

either create two queues or use notifiers...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(4,682 Views)

just one more question:

 

My two consumer loops have a very fast loop cycle time, and the producer loop has a slow loop time (many GPIB reads).

In this case because there is no danger to loose data, Can I just replace the queue structure with Notifiers? So I do nod have to use two queues...

Thanks!

0 Kudos
Message 3 of 10
(4,672 Views)

Hi Blokk,

 

"no danger" is quite optimistic in software development, but in this case you may use notifiers...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(4,658 Views)

I see 🙂

The master loop has about 12 seconds loop time, and what I do in the two slave loops with the data, will take no more than 1 second.

 

Thanks very much for help! 🙂

0 Kudos
Message 5 of 10
(4,655 Views)

@Blokk wrote:

Hi!

 

What is the best way for the following:

 

I enqueu data in my producer loop. I need this data dequeue-d in both of my consumer loops, but I want to dequeu the same element in both loops.

 

Of course if I put dequeues in both loop, then the second consumer loop will loose the odd elements and the first consumer loop will loose the even elements.

 

thanks!

 


Makes very little sence- that is, the problem is stated in such a way as to preclude an informative response

 

 


 

Gerd wrote"

either create two queues or use notifiers...

Best regards,
GerdW


Usually, Gerd gives good advice but on this one I'm going to pick on him just a bit- I bet he rushed in just a tad without thinking about the premise of the OP's question - and Gerd I don't mean to sound mean, my appologies

 

 

The question pre-supposes that to use a queue element twice in parallel it must be read twice.  This is false and led to less than optimal advice.  What about a template like shown in this snippet? 

undefined

 

We can certainly dequeue once and spawn as many independant actions as we need within a single consumer loop!  Much more scalable than creating a queue for each action.

 

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 10
(4,615 Views)

A notifier however is a very effective way to broadcast a message to multiple listeners. Notifiers also scale very easily.



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
Message 7 of 10
(4,610 Views)

Now I work with the notifiers, but thanks very much for the nice and simple idea with the queue! 🙂

0 Kudos
Message 8 of 10
(4,601 Views)

 


@Mark Yedinak wrote:

A notifier however is a very effective way to broadcast a message to multiple listeners. Notifiers also scale very easily.


Certainly correct!  and with the OP's situation where the consumers are faster than the producer a fine choice for now.  when the relative speeds become closer the notifier solution can loose data.  I intended to provide an alternate method for more general application.  Thanks for the input

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 10
(4,591 Views)

Everyone,

 

loose = not tight

 

lose = not found

 

Smiley Wink

Message 10 of 10
(4,577 Views)