Skip to content
Snippets Groups Projects
Commit 6383f253 authored by Lars Kanis's avatar Lars Kanis
Browse files

Add windows implementation for fxrb_wakeup_fox()

parent 5f9fb860
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,9 @@ extern "C" { ...@@ -36,7 +36,9 @@ extern "C" {
#include <sys/time.h> /* For struct timeval */ #include <sys/time.h> /* For struct timeval */
#endif #endif
#include <fcntl.h> #ifndef WIN32
#include <fcntl.h>
#endif
// Message map // Message map
FXDEFMAP(FXRbApp) FXRbAppMap[]={ FXDEFMAP(FXRbApp) FXRbAppMap[]={
...@@ -50,7 +52,11 @@ FXDEFMAP(FXRbApp) FXRbAppMap[]={ ...@@ -50,7 +52,11 @@ FXDEFMAP(FXRbApp) FXRbAppMap[]={
// Class implementation // Class implementation
FXRbIMPLEMENT(FXRbApp,FXApp,FXRbAppMap,ARRAYNUMBER(FXRbAppMap)) FXRbIMPLEMENT(FXRbApp,FXApp,FXRbAppMap,ARRAYNUMBER(FXRbAppMap))
#ifdef WIN32
WSAEVENT FXRbApp::interrupt_event = NULL;
#else
int FXRbApp::interrupt_fds[2] = {-1, -1}; int FXRbApp::interrupt_fds[2] = {-1, -1};
#endif
// Constructor // Constructor
FXRbApp::FXRbApp(const FXchar* appname,const FXchar* vendor) : FXApp(appname,vendor),m_bThreadsEnabled(FALSE),sleepTime(100){ FXRbApp::FXRbApp(const FXchar* appname,const FXchar* vendor) : FXApp(appname,vendor),m_bThreadsEnabled(FALSE),sleepTime(100){
...@@ -74,8 +80,13 @@ void FXRbApp::setThreadsEnabled(FXbool enabled){ ...@@ -74,8 +80,13 @@ void FXRbApp::setThreadsEnabled(FXbool enabled){
if(!m_bThreadsEnabled){ if(!m_bThreadsEnabled){
m_bThreadsEnabled=TRUE; m_bThreadsEnabled=TRUE;
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
#ifdef WIN32
interrupt_event = CreateEvent(NULL, TRUE, FALSE, NULL);
addInput(interrupt_event,INPUT_READ,this,ID_CHORE_THREADS);
#else
pipe2(interrupt_fds, O_NONBLOCK); pipe2(interrupt_fds, O_NONBLOCK);
addInput(interrupt_fds[0],INPUT_READ,this,ID_CHORE_THREADS); addInput(interrupt_fds[0],INPUT_READ,this,ID_CHORE_THREADS);
#endif
#else #else
addChore(this,ID_CHORE_THREADS); addChore(this,ID_CHORE_THREADS);
#endif #endif
...@@ -110,9 +121,13 @@ long FXRbApp_onChoreThreads_gvlcb(FXRbApp *self,FXObject *obj,FXSelector sel,voi ...@@ -110,9 +121,13 @@ long FXRbApp_onChoreThreads_gvlcb(FXRbApp *self,FXObject *obj,FXSelector sel,voi
// Process threads // Process threads
long FXRbApp::onChoreThreads_gvlcb(FXObject*,FXSelector,void*){ long FXRbApp::onChoreThreads_gvlcb(FXObject*,FXSelector,void*){
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
#ifdef WIN32
ResetEvent(interrupt_event);
#else
char byte; char byte;
// clear the pipe // clear the pipe
read(interrupt_fds[0], &byte, 1); read(interrupt_fds[0], &byte, 1);
#endif
#else #else
// Pause for 'sleepTime' millseconds // Pause for 'sleepTime' millseconds
struct timeval wait; struct timeval wait;
...@@ -139,7 +154,11 @@ long FXRbApp::onChoreThreads_gvlcb(FXObject*,FXSelector,void*){ ...@@ -139,7 +154,11 @@ long FXRbApp::onChoreThreads_gvlcb(FXObject*,FXSelector,void*){
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
void fxrb_wakeup_fox(void *){ void fxrb_wakeup_fox(void *){
#ifdef WIN32
SetEvent(FXRbApp::interrupt_event);
#else
int l = write(FXRbApp::interrupt_fds[1], "X", 1); int l = write(FXRbApp::interrupt_fds[1], "X", 1);
#endif
} }
#endif #endif
......
...@@ -118,7 +118,11 @@ protected: ...@@ -118,7 +118,11 @@ protected:
FXbool m_bThreadsEnabled; FXbool m_bThreadsEnabled;
FXuint sleepTime; FXuint sleepTime;
public: public:
#ifdef WIN32
static WSAEVENT interrupt_event;
#else
static int interrupt_fds[2]; static int interrupt_fds[2];
#endif
protected: protected:
FXRbApp(){} FXRbApp(){}
public: public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment