Quite new to the party, but not to coding in general. But async programming in SP is new to me
Running SP 3.2.2 on Win and trying to understand the internals of thread communication.
With my latest test, I had created nested
live_loops to be able:
- to send a cue from the end of
:intro(which then stops)
- to the loop which waits for the
sync :intro=> to start the inner
- the example is simplified
The goal I try to achieve, is to have a boolean flag
stop_main, which I want to change in live-coding.
The issue is, that when I have two nested
live_loop the live-coding change of
stop_main true is NOT be visible in the inner
So I’ve just found out that replacing
live_loop :start_main do with
in_thread do seems to work!
- Can someone pls explain to me what the difference here is?
- Is there another pattern how to make live-code changes (i.e. to variables) visible to nested
live_loop :intro do 4.times do play :a3 sleep 0.125 end cue :intro stop end stop_main = false live_loop :start_main do ##| in_thread do sync :intro live_loop :main do 4.times do play :c4 sleep 0.25 end puts "stop_main: ", stop_main stop if stop_main end end