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.

Reply via email to