On Tue, 07 May 2013 00:03:58 +0100, Sean Kelly <s...@invisibleduck.org> wrote:

On May 2, 2013, at 6:17 AM, Regan Heath <re...@netmail.co.nz> wrote:

On Wed, 01 May 2013 01:12:39 +0100, Sean Kelly <s...@invisibleduck.org> wrote:

On Apr 23, 2013, at 2:21 PM, Jack Applegame <jappleg...@gmail.com> wrote:

According WinAPI documentation, CtrlHandler will be called in new additional thread. Is it safe to allocate GC memory in NOT Phobos threads? If not, how to make it safe? I'm trying call thread_attachThis() at the beginning of CtrlHandler fucntion, but it doesn't compile because thread_attachThis() is not no throw.


thread_attachThis should probably just be labeled nothrow. I don't think there's anything in that function that can throw an Exception.

That makes it callable.. but did you see my post about the various timing issues with using this in a non-GC thread (potentially while the GC is already collecting - or similar).

The GC holds a lock on the global thread list while collecting, so it shouldn't be possible for thread_attachThis to register a thread when this is happening. In fact, thread_attachThis even temporarily disables the GC, and since this operation is protected by the GC lock, it's blocked there as well.

Excellent. Might be nice to see some of these details in the docs :p .. or even just a "will block if collection is in progress".

R

--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to