[D-runtime] A mechanism to kill threads

Alex Rønne Petersen xtzgzorex at gmail.com
Wed May 16 17:55:48 PDT 2012


One interesting question in designing a kill function is: Do we want
to guarantee that it runs all the thread shutdown routines (see the
shutdown code in thread_entryPoint)? I'm thinking that guaranteeing
this is basically impossible, so I'm leaning towards no. The most I
can see would be realistic is to remove the thread from the global
thread list if enqueueing the termination request (pthread_cancel on
POSIX, TerminateThread on Windows) succeeded.

If we don't guarantee this, how much resource leakage are we looking at?

Regards,
Alex

On Wed, May 16, 2012 at 7:04 PM, Alex Rønne Petersen
<xtzgzorex at gmail.com> wrote:
> Hi,
>
> In my virtual machine, I need to be able to kill daemon threads on
> shutdown. The problem is that VM shutdown is *not* tightly coupled to
> druntime shutdown; multiple VM instances can run in a process at any
> given time, and can be started/stopped whenever. It doesn't appear
> like there is any functionality in core.thread to achieve this.
>
> Is there any reason we don't have a Thread.kill() function?
>
> Regards,
> Alex


More information about the D-runtime mailing list