Re: WinAPI callbacks and GC

2013-05-07 Thread Regan Heath
On Tue, 07 May 2013 00:03:58 +0100, Sean Kelly wrote: On May 2, 2013, at 6:17 AM, Regan Heath wrote: On Wed, 01 May 2013 01:12:39 +0100, Sean Kelly wrote: On Apr 23, 2013, at 2:21 PM, Jack Applegame wrote: According WinAPI documentation, CtrlHandler will be called in new additio

Re: WinAPI callbacks and GC

2013-05-06 Thread Sean Kelly
On May 2, 2013, at 6:17 AM, Regan Heath wrote: > On Wed, 01 May 2013 01:12:39 +0100, Sean Kelly wrote: > >> On Apr 23, 2013, at 2:21 PM, Jack Applegame wrote: >>> >>> According WinAPI documentation, CtrlHandler will be called in new >>> additional thread. Is it safe to allocate GC memory in

Re: WinAPI callbacks and GC

2013-05-02 Thread Regan Heath
On Wed, 01 May 2013 01:12:39 +0100, Sean Kelly wrote: On Apr 23, 2013, at 2:21 PM, Jack Applegame 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

Re: WinAPI callbacks and GC

2013-04-30 Thread Sean Kelly
On Apr 23, 2013, at 2:21 PM, Jack Applegame 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 CtrlHand

Re: WinAPI callbacks and GC

2013-04-24 Thread evilrat
On Wednesday, 24 April 2013 at 09:51:29 UTC, Regan Heath wrote: Until then, I would perform manual memory allocation. I am not sure how in D, but you need something like "placement new" to construct a class in a previously allocated block of memory (allocated with malloc or similar). look at

Re: WinAPI callbacks and GC

2013-04-24 Thread Regan Heath
On Tue, 23 Apr 2013 22:21:27 +0100, Jack Applegame wrote: I'm writing Ctrl-C handler for console application for Windows: extern(Windows) { int CtrlHandler(uint flag) nothrow { auto tmp = new SomeClass; // is it safe? ... return true; } } ... SetConsoleCtrlHandler(&Ctr

Re: WinAPI callbacks and GC

2013-04-23 Thread evilrat
On Tuesday, 23 April 2013 at 21:21:28 UTC, Jack Applegame wrote: 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 nothrow. what stops you from calling normal functions in nothr

Re: WinAPI callbacks and GC

2013-04-23 Thread evilrat
On Tuesday, 23 April 2013 at 21:21:28 UTC, Jack Applegame wrote: I'm writing Ctrl-C handler for console application for Windows: extern(Windows) { int CtrlHandler(uint flag) nothrow { auto tmp = new SomeClass; // is it safe? ... return true; } } ... SetConsoleCtrlHandler(&CtrlH

WinAPI callbacks and GC

2013-04-23 Thread Jack Applegame
I'm writing Ctrl-C handler for console application for Windows: extern(Windows) { int CtrlHandler(uint flag) nothrow { auto tmp = new SomeClass; // is it safe? ... return true; } } ... SetConsoleCtrlHandler(&CtrlHandler, true); ... According WinAPI documentation, CtrlHandler w