From 9b93d9417b6c000add553eba5e3d121724a309a2 Mon Sep 17 00:00:00 2001 From: Lars Kanis <lars@greiz-reinsdorf.de> Date: Mon, 6 Jul 2015 21:44:10 +0200 Subject: [PATCH] Move the clearing of the event before the call to rb_thread_call_with_gvl(). This should ensure, that the event is definitely cleared. These functions should be thread safe. --- ext/fox16_c/FXRbApp.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ext/fox16_c/FXRbApp.cpp b/ext/fox16_c/FXRbApp.cpp index 89120a9..5968ad3 100644 --- a/ext/fox16_c/FXRbApp.cpp +++ b/ext/fox16_c/FXRbApp.cpp @@ -111,6 +111,15 @@ FXuint FXRbApp::getSleepTime() const { } long FXRbApp::onChoreThreads(FXObject *obj,FXSelector sel,void *p){ +#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) +#ifdef WIN32 + ResetEvent(interrupt_event); +#else + char byte; + // clear the pipe + read(interrupt_fds[0], &byte, 1); +#endif +#endif return FXRbApp_onChoreThreads(this, obj, sel, p); } @@ -121,13 +130,6 @@ long FXRbApp_onChoreThreads_gvlcb(FXRbApp *self,FXObject *obj,FXSelector sel,voi // Process threads long FXRbApp::onChoreThreads_gvlcb(FXObject*,FXSelector,void*){ #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) -#ifdef WIN32 - ResetEvent(interrupt_event); -#else - char byte; - // clear the pipe - read(interrupt_fds[0], &byte, 1); -#endif #else // Pause for 'sleepTime' millseconds struct timeval wait; @@ -157,7 +159,7 @@ void fxrb_wakeup_fox(void *){ #ifdef WIN32 SetEvent(FXRbApp::interrupt_event); #else - int l = write(FXRbApp::interrupt_fds[1], "X", 1); + write(FXRbApp::interrupt_fds[1], "X", 1); #endif } #endif -- GitLab