[chuck-users] Stopping and restart shreds

w31rd0 w31rd0 at mail.ru
Wed Jul 26 03:57:14 EDT 2006


> Currently in ChucK, a parent shred will terminate any child shreds
when
> the parent terminates. For example:
> 
> ---
> // start
> fun void foo()
> {
> <<< "foo!!!" >>>;
> }
> 
> // spork foo
> spork ~ foo();
> 
> // end of program
> ---
> 
> In this case, "foo" will NOT print because the parent shred has exited
> before the child has a chance to run. As Kassen mentioned, advancing
time
> in the parent shred will allow children to execute. If no time advance
is
> desired, me.yield() should work.
> 
> ---
> // start
> fun void foo()
> {
> <<< "foo!!!" >>>;
> }
> 
> // spork foo
> spork ~ foo();
> 
> // yield to let foo run, no time advance
> me.yield();
> 
> // end of program
> ---
> 
> Hope this helps.

Yep. Unless foo() is doing something non-trivial.

For example,

dur T1;
dur T2;

fun void foo()
{
    T1 => now;
    <<< "foo!!!" >>>;
}

// spork foo
spork ~ foo();

T2 => now;

In this case "foo" will print only if T2 > T1.


___________________
w31rd0




More information about the chuck-users mailing list