<div dir="ltr">Atte:<br><br>I don't know if this is directly relevant to your overall goal, but for my many hours of real-time performance work, I found the following construct to be 100% bullet proof.<div><br></div><div>The idea is that you assign the Shred to a variable, e.g. _phoneme_handle, when you spork the shred. When you want to stop the shred, you don't directly kill it -- instead, you set the variable to something else (e.g. null). Within the shred's main processing loop, you compare the value of _phoneme_handle against "me", and stop processing if they differ. This approach cleanly avoids any race conditions associated with starting and stopping shreds:</div><div><br></div><div><div><div> // called when the note first starts.</div><div> fun Vox note_started() { </div><div><span class="Apple-tab-span" style="line-height:1.5;font-size:13.1999998092651px;white-space:pre">        </span><span style="line-height:1.5;font-size:13.1999998092651px">spork ~ _phoneme_proc() @=> _phoneme_handle; // start babbling</span><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span><span style="line-height:1.5;font-size:13.1999998092651px">_vox => AudioIO.output_bus();</span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return this; </div><div> }</div><div><br></div><div> // called when note has finished.</div><div> fun Vox note_ended() { </div><div><span class="Apple-tab-span" style="line-height:1.5;font-size:13.1999998092651px;white-space:pre">        </span><span style="line-height:1.5;font-size:13.1999998092651px">null @=> _phoneme_handle; // stop babbling</span><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>_vox =< AudioIO.output_bus();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return this; </div><div> }</div><div><br></div></div><div><div> // shred that modifies phonemes</div><div> fun void _phoneme_proc() {</div><div><span class="Apple-tab-span" style="line-height:1.5;font-size:13.1999998092651px;white-space:pre">        </span><span style="line-height:1.5;font-size:13.1999998092651px">while (me == _phoneme_handle) {</span><br></div><div><span class="Apple-tab-span" style="line-height:1.5;font-size:13.1999998092651px;white-space:pre">        </span><span style="line-height:1.5;font-size:13.1999998092651px"> // ... do stuff until _phoneme_handle changes</span></div><div><span class="Apple-tab-span" style="line-height:1.5;font-size:13.1999998092651px;white-space:pre">        </span><span style="line-height:1.5;font-size:13.1999998092651px">}</span><br></div><div><span class="Apple-tab-span" style="line-height:19.7999992370605px;font-size:13.1999998092651px;white-space:pre">        </span>// here when the shred is absolutely about to exit</div><div><span style="line-height:1.5;font-size:13.1999998092651px"> }</span><br></div></div><div><br></div><div><br></div></div></div><br><div class="gmail_quote">On Sun, 15 Mar 2015 at 01:58 Atte <<a href="mailto:atte@youmail.dk">atte@youmail.dk</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 03/15/2015 09:43 AM, Atte wrote:<br>
> On 03/09/2015 01:57 PM, Atte wrote:<br>
> I've cut down the scenario as much as possible,<br>
> three files,<br>
<br>
Might be obvious, but run with<br>
<br>
$ chuck <a href="http://lib_sporker.ck" target="_blank">lib_sporker.ck</a> <a href="http://sporker.ck" target="_blank">sporker.ck</a><br>
<br>
Cheers<br>
--<br>
Atte<br>
<br>
<a href="http://atte.dk" target="_blank">http://atte.dk</a> <a href="http://a773.dk" target="_blank">http://a773.dk</a><br>
______________________________<u></u>_________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.<u></u>princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" target="_blank">https://lists.cs.princeton.<u></u>edu/mailman/listinfo/chuck-<u></u>users</a><br>
</blockquote></div>