[D-runtime] A mechanism to kill threads

Jonathan M Davis jmdavisProg at gmx.com
Wed May 16 14:04:48 PDT 2012


On Wednesday, May 16, 2012 20:57:15 Alex Rønne Petersen 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?

Well, I wasn't saying that it's necessarily the case that we shouldn't add it. 
I was pointing out that it's a very unsafe thing to do and rarely needed such 
that it's not exactly surprising that it hasn't been added previously. If 
there's a real use case for it, it makes sense to add it given that it _is_ 
something that's platform dependent, and part of the whole point of Thread is 
to provide a platform-independent API for handling threads. It probably 
_should_ have a big fat warning on it though, given that not all developers 
seem to get how insanely bad it is to kill a thread (at least, that seems to 
be the case given some thread-related questions I've seen in the past).

- Jonathan M Davis


More information about the D-runtime mailing list