static void wake_up_thread(HANDLE thread) { if (!CancelSynchronousIo(thread)) { DWORD err = GetLastError(); // CancelSynchronousIo() didn't find anything to cancel, let's try // with QueueUserAPC() instead. if (err == ERROR_NOT_FOUND) { if (!QueueUserAPC(&dummy_cb, thread, NULL)) { fatal_error("QueueUserAPC() failed", GetLastError()); } } else { fatal_error("CancelSynchronousIo() failed", err); } } }
// Not available on *nix platforms static inline void cancelIO(const Thread &t) { if (t._th != NULL) CancelSynchronousIo(t._th); }