[chuck-users] spork question

Tom Lieber tom at alltom.com
Sat Aug 15 16:38:41 EDT 2009


2009/8/15 Bozelos Dimitris <dbozelos at yahoo.gr>:
> class TEnvelope
> {
>     fun void TFunction( int milliseconds )
>     {
>         <<< "before", now >>>;
>         milliseconds::ms => now;
>         <<< "after", now >>>;
>     }
> }
>
> class StereoTEnvelope
> {
>     TEnvelope envelopeL;
>     TEnvelope envelopeR;
>
>     fun void TFunction( int milliseconds )
>     {
>         spork ~ envelopeL.TFunction( milliseconds );
>         envelopeR.TFunction( milliseconds );
>     }
> }
>
> class TTest
> {
>     StereoTEnvelope envelope;
>
>     fun void TFunction( int milliseconds )
>     {
>         envelope.TFunction( milliseconds );
>     }
> }
>
> and then I do:
>
> ( TTest tTest ).TFunction( 5000 );
>
> The function in StereoTEnvelope that I call with envelope.TFunction proceeds
> as expected printing 'now' both before and after advancing time. But the
> function that I spork prints only before and then quits.
>
> ?????

The parent shred dies, killing the child shred you sporked, before it
can print its second message. Try:

( TTest tTest ).TFunction( 5000 );
me.yield();

-- 
Tom Lieber
http://AllTom.com/


More information about the chuck-users mailing list