WinAPI callbacks and GC
Jack Applegame
japplegame at gmail.com
Tue Apr 23 14:21:27 PDT 2013
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 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 nothrow.
More information about the Digitalmars-d-learn
mailing list