[D-runtime] A mechanism to kill threads
Fawzi Mohamed
fawzi at gmx.ch
Wed May 16 14:07:10 PDT 2012
On Wed, 16 May 2012 20:57:15 +0200
Alex Rønne Petersen <xtzgzorex at gmail.com> wrote:
> Of course it's unsafe, but no less than arbitrarily suspending a
> thread. Once you've suspended a thread, you may as well kill it.
> You've effectively halted it anyway. We have lots of unsafe primitives
> in core.thread already (and my critical regions and cooperative
> suspension patches add even more!).
>
> Is there anything speaking against adding this to core.thread with a
> big fat "THIS IS UNSAFE" warning?
yes, suspending makes the code that is executed during the suspension
"unsafe" (meaning that it can do only things that can be done in a
signal handler).
Killing makes all the rest of the program have such constraints...
Fawzi
>
> Regards,
> Alex
>
> On Wed, May 16, 2012 at 8:47 PM, Jonathan M Davis
> <jmdavisProg at gmx.com> wrote:
> > On Wednesday, May 16, 2012 19:04:48 Alex Rønne Petersen 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?
> >
> > Because it's incredibly unsafe? You may have a valid use case for
> > it, but it's _not_ something that you should normally be doing.
> >
> > - Jonathan M Davis
> > _______________________________________________
> > D-runtime mailing list
> > D-runtime at puremagic.com
> > http://lists.puremagic.com/mailman/listinfo/d-runtime
> _______________________________________________
> D-runtime mailing list
> D-runtime at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/d-runtime
More information about the D-runtime
mailing list