<br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I wish I had some examples of sporked shreds sharing data with each<br>other, for instance.
</blockquote><div><br><br>Ok. Let&#39;s not go into sharing data between shreds that come from different .ck files just now as that&#39;s slightly advanced (but not that hard either).<br><br>For shreds that come from the same file, (this comes down to paralel sporked functions) there are a few things to keep in mind. Anything that gets defined inside of a function&#39;s definition {between the brackets} is that function&#39;s data and is seperate from there rest. However; anything that gets defined in the main text is shared by everything in that file. This includes ugen parameters. I&#39;ll demonstrate this now. In the code below we&#39;ll define a variable that is shared between paralel shreds and we&#39;ll have one shred writing to it and have the other shred print it.
<br>=========================<br>int shared;<br><br>fun void writer()<br>{<br>//let&#39;s just define another variable<br>int example;<br><br>while(true)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; Std.rand2(0, 10) =&gt; shared;<br>&nbsp;&nbsp;&nbsp; second =&gt; now;
<br>&nbsp;&nbsp;&nbsp; }<br>}<br></div><br><br>fun void reader()<br>
{<br>//notice how this &quot;example&quot; won&#39;t clash with the other one<br>//as each function has it&#39;s own namespace.<br>//if you&#39;d like to share data it would be a mistake to also<br>//define a second int named &quot;shared&quot; here as that would confuse things.
<br>int example;<br>
<br>
while(true)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &lt;&lt;&lt;shared&gt;&gt;&gt;;<br>
&nbsp;&nbsp;&nbsp; second =&gt; now;<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
<br>spork ~ writer();<br>spork ~ reader();<br><br>while(true)<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &lt;&lt;&lt;&quot;hello, I&#39;m the main shred, I&#39;m still alive!&quot;&gt;&gt;&gt;;<br>&nbsp;&nbsp; 5::second =&gt; now;<br>&nbsp;&nbsp; }<br>==========================
<br>
<br><br>This would be the most basic way to share data between shreds. I&#39;d be happy to give more advanced examples if that&#39;s nesicary but in that case I&#39;d have to know what direction you want to move in.<br><br>
Also; I&#39;m dyslexic and didn&#39;t test this code, just warning you :¬)<br><br><br>Yours,<br>Kas.<br></div>