04-25-2022 12:57 PM
@billko wrote:
@David99999 wrote:
Would a channel writer/reader setup be better than a local variable for sharing data between loops?
Probably over a billion times better, but I didn't check the math on that.
I ran the numbers a while back and it's actually 1,000,000,000.33 (repeating, of course).
04-26-2022 04:34 AM
@David99999 wrote:
Would a channel writer/reader setup be better than a local variable for sharing data between loops?
Channel wires were created to communicate between loops and they do it really well. Start here. I use them all the time for simple tasks like this and for much more complex message/actor-based architectures, and they always do their job, as well as make the code more readable.
04-26-2022 06:18 AM
@David99999 wrote:
Would a channel writer/reader setup be better than a local variable for sharing data between loops?
That depends on the channel wire type.
If you use a 'tag' channel wire (basically a current value), I don't think there's much difference regarding race conditions.
But once you start putting things in sub VIs (not possible with locals), at least you have a wire to track.
If you use a messenger or stream, the loops are synchronized, and you probably might as well use 1 loop.
04-26-2022 11:14 PM
wiebe@CARYA wrote:
If you use a messenger or stream, the loops are synchronized, and you probably might as well use 1 loop
I don't believe this is true.
What about a stream in a Producer/Consumer or SMH architecture?
04-27-2022 06:49 AM
@RTSLVU wrote:
wiebe@CARYA wrote:
If you use a messenger or stream, the loops are synchronized, and you probably might as well use 1 loop
I don't believe this is true.
What about a stream in a Producer/Consumer or SMH architecture?
I think Wiebe went too generic in his comment. From other conversations I have had with him, I'm pretty sure he was trying to refer to "Synchronous Communication" where loop 1 sends a command/request to loop 2 and then waits for a reply. This is a form of synchronization that would make one think about if multiple loops is actually needed.
04-27-2022 09:05 AM - edited 04-27-2022 09:13 AM
@RTSLVU wrote:
wiebe@CARYA wrote:
If you use a messenger or stream, the loops are synchronized, and you probably might as well use 1 loop
I don't believe this is true.
What about a stream in a Producer/Consumer or SMH architecture?
In the context of the use case OP is picturing...
instead of a local, use a stream\messenger channel wire between two loops makes little sense (to me)...
04-27-2022 09:14 AM - edited 04-27-2022 09:15 AM
wiebe@CARYA wrote:
In the use case OP is picturing...
Sure, but the OP's cases are not real world cases.
But they are common mistakes of using locals
04-27-2022 11:27 AM
@RTSLVU wrote:
wiebe@CARYA wrote:
In the use case OP is picturing...
Sure, but the OP's cases are not real world cases.
But they are common mistakes of using locals
I concur...
05-05-2022 07:08 AM
Hi,
Local variable is not advisable to use inside the same loop. Instead you can use Functional Global variable. i have attached a reference of your code based on FGV. kindly refer that.
05-05-2022 07:35 AM
@Magesh003 wrote:
Hi,
Local variable is not advisable to use inside the same loop. Instead you can use Functional Global variable. i have attached a reference of your code based on FGV. kindly refer that.
While an FGV would work here, it is completely unjustified. Just use the wire. Think dataflow!