[chuck-users] Returning a Shred and crashing Chuck

mike clemow gelfmuse at gmail.com
Fri Jun 13 02:20:23 EDT 2008


Hi folks!

Riddle me this...

This destroys poor Chuck after a short time:

-----
class Forkable {
    // I am a process
    fun void run() {
        // sporkable code here...
        SinOsc s => dac;
        100::ms => now;
        me.yield();
    }
}

class Forker {
    // I fork a process (Forkable)
    fun Shred fork( Forkable f ) {
        // code that forks a Forkable
        spork ~ f.run() @=> Shred @ offspring;   // RETURNING A SHRED OBJECT
        me.yield();
        return offspring;
    }
}

Forkable forkable;
Forker forker;

while( true ) {
    forker.fork( forkable );
    50::ms => now;
}

-----
This, however, does not:
-----

class Forkable {
    // I am a process
    fun void run() {
        // sporkable code here...
        SinOsc s => dac;
        100::ms => now;
        me.yield();
    }
}

class Forker {
    // I fork a process (Forkable)
    fun void fork( Forkable f ) {
        // code that forks a Forkable
        spork ~ f.run();       // NOT RETURNING THE SHRED OBJECT HERE
        me.yield();
    }
}

Forkable forkable;
Forker forker;

while( true ) {
    forker.fork( forkable );
    50::ms => now;
}
-----

What gives?  It apparently doesn't like the return of the Shred
object.  I'm not sure what's happening here.  It's not *really* that
important to me, but it would be nice to have the option of killing
that process later.

Any ideas?  Am I doing something wrong???

Cheers,
Mike

-- 
http://semiotech.org
http://deadlylittlepills.com/michael


More information about the chuck-users mailing list