LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to wait on a queue and on a notifier at the same time?

Solved!
Go to solution

@AStankov wrote:

@JÞB wrote:

Good question!  FGV vs Notifier as offered.  To the best of my knowledge the syncronization primitives are slightly higher in performance than a subiv call. So the performance would depend on the sparseness of the queue.  if there are normally few or no elements enqueued the solution offered would be better, if there are a great many elements in the queue two calls to a fgv (and an alternate slider command filter, such as a dedicated single element queue) could be slightly better.  Again, this problem is user interface so CPU optomization is not really the largest problem.  Getting the users desired actions to execute is the goal. 

And yes Tim is Crossrulz, sorry for any confussion.  I tend to refer to my fellow LabVIEW Champions familiarlly out of respect. Just a minor point of forum ettiquette that is probably not written anywhere and I made up in my own head- no worries.


Jeff, thank you for the clarifications. I am still thinking if I really need the notifier. If I use a queue that transports messages + data and if I have to dequeue all elements anyway (I think you are actually doing this by calling the flush), I could probably just replace a dequeued "slider" message with my updated "slider" message and get rid of the notifier. All other messages will be just reenqueued. If no "slider" message is found, I will simply enqueue my latest "slider" message at the end. I thought that dequeueing and reenqueueing the complete queue would not be very efficient but his is probably no big problem.


Exactly,  You are not abusing the CPU by tasking it with extra actions to forgive your user for being slow and indecisive.  Its a tool to work for the user.  We aren't it's slaves triing to make its job as easy as possible.


"Should be" isn't "Is" -Jay
0 Kudos
Message 21 of 37
(1,189 Views)

@JÞB wrote:

Exactly,  You are not abusing the CPU by tasking it with extra actions to forgive your user for being slow and indecisive.  Its a tool to work for the user.  We aren't it's slaves triing to make its job as easy as possible.

Well, when my old notebook starts sounding like a hairdryer I am not sure about that 😉 I will try myself and decide whether to use your solution or Tim's original proposal. Thank you all once again for the help.

0 Kudos
Message 22 of 37
(1,182 Views)

An addition to Jeff's solution:

 

Looks like one may simply use "Get Queue Status" to get all elements from the queue without removing them. This will speed up things, as there is no need to dequeue and reenqueue everything 🙂

0 Kudos
Message 23 of 37
(1,170 Views)

@AStankov wrote:

An addition to Jeff's solution:

 

Looks like one may simply use "Get Queue Status" to get all elements from the queue without removing them. This will speed up things, as there is no need to dequeue and reenqueue everything 🙂


This will create a copy of all the elements because it needs to keep the elements in the queue and return a copy of them to you. Also, if you are looking to replace the data of an element already on the quueue you will need to flush the queue and requeue everything. There is no way to modify an element that is on the queue.



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 24 of 37
(1,168 Views)

@Mark_Yedinak wrote:

This will create a copy of all the elements because it needs to keep the elements in the queue and return a copy of them to you. Also, if you are looking to replace the data of an element already on the quueue you will need to flush the queue and requeue everything. There is no way to modify an element that is on the queue.

But does Flush Queue not also create a copy when it returns all elements in an array? In Jeff's example no data is replaced, it simply looks if such an element already exists in the queue, if it doesn't the element is enqueued normally, otherwise the queue is not changed at all.

0 Kudos
Message 25 of 37
(1,163 Views)

I don't think the flush would need to create a copy. It can simply give you the current set of elements. Also, I thought you had mentioned that you could look for an existing element (slider message) and update its data with the new value. In order to do this the queue must be flushed and everything requeued. If you are simply checking the queue you can use the queue status.



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 26 of 37
(1,158 Views)

@Mark_Yedinak wrote:

I don't think the flush would need to create a copy. It can simply give you the current set of elements. Also, I thought you had mentioned that you could look for an existing element (slider message) and update its data with the new value. In order to do this the queue must be flushed and everything requeued. If you are simply checking the queue you can use the queue status.


Regarding the message update you are right, but in the meantime I think about using a notifier or simply a FGV that will be read in the consumer. This FGV will always hold the latest value and I won't need to requeue.

Regarding the flush that's interesting. Is there any evidence that LabVIEW will just be able to map a complete queue to an array as it is flushed?

 

0 Kudos
Message 27 of 37
(1,152 Views)

@AStankov wrote:

@Mark_Yedinak wrote:

I don't think the flush would need to create a copy. It can simply give you the current set of elements. Also, I thought you had mentioned that you could look for an existing element (slider message) and update its data with the new value. In order to do this the queue must be flushed and everything requeued. If you are simply checking the queue you can use the queue status.


Regarding the message update you are right, but in the meantime I think about using a notifier or simply a FGV that will be read in the consumer. This FGV will always hold the latest value and I won't need to requeue.

Regarding the flush that's interesting. Is there any evidence that LabVIEW will just be able to map a complete queue to an array as it is flushed?

 


With some of these compiler optomizations we've been seeing I wouldn't be a bit surprised if the flush/requeue operation didn't even move the data in memory and just destroyed a pointer, created a poiner to the same data, detroyed the new pointer and recteated the original. Heck, even that might get recognized as a "no value change" and the operation could be done with no overhead.  It would take a heck of a lot to benchmark it though.

 

From a stict performance perspective  Its the search array thats the killer queues are fast.


"Should be" isn't "Is" -Jay
0 Kudos
Message 28 of 37
(1,148 Views)

I would opt for the notifier over the FGV.



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 29 of 37
(1,135 Views)

@Mark_Yedinak wrote:

I would opt for the notifier over the FGV.


Of course, if going Jeff's route, you don't even need the notifier; the data is in the queue.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 30 of 37
(1,130 Views)