digitalmars.D - You can call Fiber.yield() inside a vectored exception handler (win32)
- Cauterite (26/26) Aug 31 2016 In case anyone was wondering, in 32-bit Windows you can call
In case anyone was wondering, in 32-bit Windows you can call Fiber.yield() from inside a vectored exception handler, and subsequently resume the fibre again. As far as I can tell it works flawlessly. Here's a little example: --- extern(Windows) int on_exception_global(EXCEPTION_POINTERS* X) nothrow { /* once installed, this function will be called for every exception raised in the current process */ if (X.ExceptionRecord.ExceptionCode == STATUS_ACCESS_VIOLATION) { Fibre.yield(); // can do! // retry the instruction that raised the exception return EXCEPTION_CONTINUE_EXECUTION; }; // call next exception handler return EXCEPTION_CONTINUE_SEARCH; }; auto Hdl = enforce(AddVectoredExceptionHandler( 1, /* insert at front of exception-handler chain */ &on_exception_global )); --- Careful about throwing from inside your exception handler (any kind of software or hardware exception, not limited to 'Throwable'). Don't want to end up in an infinite loop.
Aug 31 2016