01-16-2012 04:01 PM
Hi, I want to pass one variable from Loop A to Loop B, I am wonder which one is more effective, Notification or local variabe?
Solved! Go to Solution.
01-16-2012 04:39 PM
Well, they both are just as effective. If it is just a one way path from loop A to loop B you can just use a local variable but you could run into issues if you need all the data. If the writer loop writes the local then it has no way of knowing if the other loop has already read it so it will overwrite it. Also the receiving loop has no way of knowing if the data has been updated. If the receiving loop only needs the most recent value then you can get away with a local. But you have to continuously read from it whereas with a notifier you can just "wake up" the receiver loop when the value is written.
01-16-2012 05:32 PM
What ^ said.
A "notifier" acts like a queue of 1 element. Same features as a queue, "dequeue element" and "wait on notification" both behave the same way when there's nothing in the pipeline.
Local variables can be used, but you've really got to be careful where and when you write to them. Generally safe with a "WORM" - Write Once, Read Many.
For passing data between loops, I highly recommend a queue so you don't lose data, and you can adjust timing independently between the two loops.