[chuck-users] Stopping and restart shreds

Kassen signal.automatique at gmail.com
Wed Jul 26 07:34:03 EDT 2006


The current way chuck works makes sense. But (and I don't know "the
> prober to do this in concurrent programming) I think it would make more
> sense to wait for child shreds to finish before terminating.

The problem with this is that childeren may very well be running forever. If
a child is structured like this;

while (true)
<<<"the world turns around">>>;
1::year => now;

It's never going to finish (lucky world!). What you could do instead is go

int the_end;
int child_done;

fun void child()
untill( the_end)
//do stuff here; potentially stuff that takes a while.
1::second => now;
//only do this after we fall out of the loop due to "the_end" becoming true.
1 => child_done;
//at this point the child is going to leave the VM due to becoming

spork ~ child();

30::second => now;

1 => the_end;

untill ( child_done)
//wait for the child to get done, could wait for multiple childeren if need
5::ms => now;
//only exit now.

This should make the parent wait for the child to get done before exiting
yet still alows the parent to kill it's childeren.

The could be typos in the above but the general idea should be clear? Does
that help?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20060726/0ba5c799/attachment.htm 

More information about the chuck-users mailing list