LabVIEW Channel Wires

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a Channel equivalent to a Stack (or a Priority Enqueue)?

The traditional LabVIEW Queue has "Enqueue at Opposite End" which can be used for two different purposes -- to implement a LIFO (Push-down) Stack, and to allow a "high priority" element to "jump to the head of the Queue".

The analog of the Queue in Channel Wires appears to be the Stream.  Is there an existing mechanism to implement either a LIFO or (one-time) "high priority" Channel equivalent?

Bob Schor

0 Kudos
Message 1 of 4
(5,696 Views)

I hope not.  FIFO queuing is natural for communication between parallel processes (the use case of channels).  LIFO stacking is not.  If you queue up A,B,C for another process, you know they will be handled A,B,C.   But stack A,B,C and they could be handled C,B,A  or A,C,B or A,B,C etc. depending on timing of the two loops involved.  "High priority" queue jumping is OK, as long as there is only one such message in existence at a time, otherwise one has the ordering indeterminacy of stacking.

0 Kudos
Message 2 of 4
(4,971 Views)

There is no stack, for exactly the reasons drjdpowell mentions.

I have built a priority queue implementation for myself as a proof of concept but there's not one shipping with LabVIEW.

> "Enqueue at Opposite End" which can be used for two different purposes

No... just one purpose. It can be used for a stack. Using it for a priority message system is a very bad idea unless the ONLY (absolute ONLY) message is "Abort". And if that's the only message you're sending, you can accomplish that by just calling Release Queue. Any other attempt to use it for priority messaging is generally a race condition unless you do herculean efforts to prevent the race. Why? Because the priority messages are added in the reverse order if they happen to stack up, and then you have a stack communication, with all the problems listed above. 🙂

Message 3 of 4
(4,971 Views)

An excellent response, and a cogent explanation.  A Kudo from me (I notice there is no Kudo generator ...).

Bob Schor

0 Kudos
Message 4 of 4
(4,971 Views)