[D-runtime] A mechanism to kill threads

Sean Kelly sean at invisibleduck.org
Wed May 16 16:22:36 PDT 2012


On May 16, 2012, at 4:06 PM, Alex Rønne Petersen wrote:

> Trust me, I've evaluated every option I could think of. Even
> cooperative suspension/killing won't cut it because a while (true);
> inside a VM thread could prevent the cooperative kill from actually
> happening at all.
> 
> E.g.:
> 
> void myThread()
> {
>    while (run)
>    {
>        runUserCode(); // if this never returns, the thread will never stop
>    }
> }

Maybe a standalone function like:

extern (C) int thread_terminateThread(Thread t);

That would at least keep it out of the public interface for the object, and move it into the realm of really unsafe or weird stuff.  Obvious caveat still being that the app may well have been left in an invalid state.


More information about the D-runtime mailing list