Re: [chuck-users] Stopping and restart shreds
I'd like to use functions to stop and restart shreds. Is this the right way to do it? It doesn't seem to be working properly - I get errors from some shreds when I thought they'd all stopped.
Shred shredA, shredB;
fun void sporkAll() { spork ~ funA() @=> shredA; spork ~ funB() @=> shredB; me.yield(); }
fun void killAllShreds() { shredA.exit(); shredB.exit(); me.yield(); }
In previous versions of chuck invoking 'exit' on shred didn't seem to work (for me). Instead I was killing shreds in this way:
shredA.id => machine.remove;
But in 1.2.0.6 'exit' seems to work properly.
Another significant note: the shred which is calling these functions must not exit. Otherwise those functions won't work for some reason.
Developers, please correct me if I'm wrong :)
The ideas about a join method sound great for the future, but I currently have threads I can't stop with either the shred.exit() machine.remove techniques. Is there any kind of kill function I can use as a workaround for now? Ollie
participants (1)
-
Ollie Glass