[chuck] returning values when sporking

Ge Wang gewang at CS.Princeton.EDU
Fri Apr 22 03:18:58 EDT 2005


Hi Matt and all!

> spork ~ sporkFun(arguments) => int value;
>
> to a function:
>
> fun int sporkFun(arguments) {returs something in here}

In chuck-1.1, there is no way to get the return value of the sporked
function.  We can't really return the value as part of the spork
operation, since the new shred now runs concurrently with the
parent shred, and may itself advance time.  What is needed is a
"join" operation later in the parent shred to let time advance until
the child shred has finished.  Only then, do we know the return
value.  This requires synchronous events from 1.2.  For now,
you are totally right in that global variables is pretty much the
only way to go.  Super ghetto on our part.

What to expect from 1.2:

spork returns reference to the new shred.  The parent shred can
wait/join on child shred, letting time advance, or query the status
of the child shred.  Still have to figure out how to cleanly get the
return type, since this may differ.  There will be a variety of ways
for shreds to talk to each other, via events and shared variables,
lookup tables, across files.

> eagerly awaiting arrays, but not envying the work by ge and the rest to
> bring them to us,

Thanks Matt for the encouragement.  We are determined to make v1.2
happen as soon as possible.  I refrain from setting another "release" 
date.
We will continue to work hard!

Best,
Ge!



More information about the chuck mailing list