08-20-2007 07:26 AM
08-20-2007 07:52 AM
Make the VI that you invoke have a queue as an input and create the thread at the envoke method and pass it to the vi. Now you have a queue on the invoker that is shared with the concurrent vi. Queues have the most flexability of the synchronization object in my opinion.
Paul
08-20-2007 08:21 AM
08-20-2007 08:59 AM
08-20-2007 09:14 AM
I would also would give the queue a try.... if you have always only one reader.
I use the functional global (LV2-style global) to 'publish' the data and queues/notifyer to tell the others... but this also depends on the amout of data you want to spread around.
Maybe in the newer versions there is a adequate replacement for functional globals, but I don't had the time to test these 'replacements'.... (And to follow altenbach, the functional global is very flexible )
08-20-2007 09:41 AM
08-20-2007 10:25 AM
08-20-2007 10:38 AM - edited 08-20-2007 10:38 AM
With the use of Preview Queue Element, a thread can determine if the message is for it or not.You can create a single queue with a cluster data type consisting of an enum (message type) and a variant (data); in fact this is a common technique. The technique you've described of using Preview Queue Element may affect your performance considerably. All of your threads will be effectively polling and only run as fast as the slowest thread. For example; if your messages contain 10 Hz, 20 Hz and 100 Hz data that are identified by an enum (data type); your 20 and 100 Hz threads will block waiting for the next 10 Hz element to be pulled from the queue by the 10 Hz thread. Queues by default are unbounded and in this scenario you might probably run out of memory and crash your app.
Message Edited by Phillip Brooks on 08-20-2007 11:45 AM
08-20-2007 11:10 AM
I usually use one named queue for each thread I create as a message reciever. Each theade has a state which is check for messages which will process messages. If you want the messages to have a blocking (synchronous) call a notification back to the caller is required. This can get complex but does work well.
Paul