[chuck-users] Stopping and restart shreds
w31rd0
w31rd0 at mail.ru
Wed Jul 26 07:08:10 EDT 2006
> > Currently in ChucK, a parent shred will terminate any child shreds
when
> > the parent terminates.
>
> 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. This way
a
> parent wouldn't have to worry how long the child is running, which I
> think is none of it's business.
>
> I have a lot of examples in my code on me explicitly having to handle
> this and it both 1) looks ugly and 2) is not that robust.
>
> BTW: would it be possible to grab the id of the child and wait for
that
> is to finish, instead of my current way (chucking a sufficiently large
> dur to now in the parent after sporking)?
You can make your children explicitly signal they are exiting, like
this:
fun void foo( Event e )
{
10::ms => now;
<<< "foo", "" >>>;
e.signal();
}
fun void bar( Event e )
{
1000::ms => now;
<<< "bar", "" >>>;
e.signal();
}
Event e1, e2;
spork ~ foo( e1 );
spork ~ bar( e2 );
e1 => now;
e2 => now;
Still ugly though ;(
___________________
w31rd0
More information about the chuck-users
mailing list