01-25-2018 10:35 AM
I can think of a few ways to make this work, but none of them seem particularly elegant:
If my program consists of a state machine, and several parallel While loops outside of that state machine, how can I ensure that those While loops don't start until I've passed completely through the "initialization" state of my machine?
I feel like wiring an event structure up to the front of all of the other loops is a really inelegant way to get them to wait. It seems better to wire an error, or something, out of the initialization state and over to each loop so they wait on that terminal - but then I'd have to wire that terminal up for every single state and etc.
Is there a better way?
01-25-2018 10:48 AM
Use a notifier. Have all of your parallel loops wait on the notifier and have the state machine generate the notification once its initialization is complete.
01-25-2018 10:51 AM
There are also Occurrences. Not as robust as a notifier, but very simple to use.
01-25-2018 10:58 AM
A large percentage of my parallel loops tend to be Queued Message Handlers. So I just send a message to those loops when I am ready for them to start doing whatever they were made to do.
01-25-2018 11:25 AM
And then there is the rendezvous...
Ben
01-25-2018 12:13 PM
@Ben wrote:
And then there is the rendezvous...
Somehow, I just knew it was going to be Ben to mention those...
01-25-2018 12:23 PM
And then there are Channels Wires
01-25-2018 12:31 PM
@crossrulz wrote:
@Ben wrote:
And then there is the rendezvous...
Somehow, I just knew it was going to be Ben to mention those...
A wise man fool goes into his store house Palettes and brings forth treasures functions both old and new.
Ben
01-25-2018 03:27 PM
Thanks for the replies everyone - a question: By "notifier," do you mean triggering an event via property node? I am doing that right now to trigger events out of my main loop but it feels kind of hack-y.
I have a boolean essentially called "condition met" which is set to T or F via property node (signaling), and the event structure picks it up and does it's thing. The downside to this is the event fires whenever the node is used, even if it's F → F or T → T, and really i'd like it to fire whenever the variable is *changed*.
I am using a bunch of case structures to work around this now, but milliseconds matter in this loop and I don't have any idea if evaluating them is taking time - so I'd really appreciate knowing if there's a faster way to do these checks and fire/not fire events programmatically.
01-25-2018 03:43 PM
No, I mean a notifier. You can find them on the synchronization palette with queues. A notifier is similar to a queue. The difference is that a notifier will only contain a single value. New notifications will overwrite the current one. Another key difference is that you can broadcast a notification. Notifiers can have multiple listeners.