On 9/3/15 5:20 PM, Matt Kline wrote:
TDPL suggests that calls to std.concurrency.send will fail with an
"OwnedTerminated" or "OwnedFailed" exception if the destination thread
has exited, but neither the docs nor the current Phobos implementation
make any mention of such exceptions. Thinking the information was just
outdated, I searched the Git history of Phobos for such types, but found
nothing.
What are current best practices for determining if a child thread has
died? And should these types be added to TDPL errata?
It seems this is not handled.
Looking here:
https://github.com/D-Programming-Language/phobos/blob/master/std/concurrency.d#L506
spawn creates the thread, then calls the function, but never sets a flag
indicating when the thread is done. This could be added quite easily by
adding a scope(exit) to the executed function (exec). It would not
happen if the thread is terminated abnormally, but any thrown exception
should trigger the flag. I'll note that the MessageBox class has a
close() method that seems like it could be called.
Anyone want to make a PR? And no, I'm not going to :)
-Steve