Commits

ecsv committed 79023f1

Readd SoftLocker which was dropped during the initial port

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
projects/unix/Makefile | 8 ++++++++
src/Glide64/Gfx #1.3.h | 2 ++
src/Glide64/Main.cpp | 2 ++
src/Glide64/rdp.cpp | 25 +++++++++++--------------
4 files changed, 23 insertions(+), 14 deletions(-)

  • Participants
  • Parent commits 6d1f4f5

Comments (0)

Files changed (4)

projects/unix/Makefile

 LDFLAGS += $(SHARED)
 LDLIBS += -lboost_filesystem-mt -lboost_system-mt -lboost_thread-mt
 
+ifeq ($(OS), MINGW)
+  CFLAGS += -lpthread
+  LDLIBS += -lpthread
+else
+  CFLAGS += -pthread
+  LDLIBS += -pthread
+endif
+
 # default configuration programs
 SDL_CONFIG = $(CROSS_COMPILE)sdl-config
 PKG_CONFIG = $(CROSS_COMPILE)pkg-config

src/Glide64/Gfx #1.3.h

 #include "m64p.h"
 
 #include <stdio.h>
+#include <pthread.h>
 #include <fstream>
 #include <stdlib.h>
 #include <stddef.h>		// offsetof
 extern int evoodoo;
 extern int ev_fullscreen;
 
+extern pthread_mutex_t mutexProcessDList;
 extern int exception;
 
 // extern wxMutex *mutexProcessDList;

src/Glide64/Main.cpp

 int    capture_screen = 0;
 char    capture_path[256];
 
+pthread_mutex_t mutexProcessDList = PTHREAD_MUTEX_INITIALIZER;
+
 // SOME FUNCTION DEFINITIONS 
 
 static void DrawFrameBuffer ();

src/Glide64/rdp.cpp

 //****************************************************************
 
 #include <math.h>
+#include <pthread.h>
 #include "Gfx #1.3.h"
 #include "m64p.h"
 #include "Ini.h"
       return;
     }
 }
-/*
+
 class SoftLocker
 {
 public:
   // lock the mutex in the ctor
-  SoftLocker(wxMutex* mutex)
+  SoftLocker(pthread_mutex_t *mutex)
     : _isOk(false), _mutex(mutex)
-  { _isOk = ( _mutex->TryLock() == wxMUTEX_NO_ERROR ); }
+  { _isOk = ( pthread_mutex_trylock(_mutex) == 0 ); }
 
   // returns true if mutex was successfully locked in ctor
   bool IsOk() const
 
   // unlock the mutex in dtor
   ~SoftLocker()
-  { if ( IsOk() ) _mutex->Unlock(); }
+  { if ( IsOk() ) pthread_mutex_unlock(_mutex); }
 
 private:
   bool     _isOk;
-  wxMutex* _mutex;
+  pthread_mutex_t *_mutex;
 };
-*/
+
 
 /******************************************************************
 Function: ProcessDList
 
 EXPORT void CALL ProcessDList(void)
 {
-  // TODO add SoftLocker
-  //SoftLocker lock(mutexProcessDList);
-  //if (!lock.IsOk()) //mutex is busy
-  if (0)
+  SoftLocker lock(&mutexProcessDList);
+  if (!lock.IsOk()) //mutex is busy
   {
     if (!fullscreen)
       drawNoFullscreenMessage();
   LOG ("ProcessRDPList ()\n");
   LRDP("ProcessRDPList ()\n");
 
-  // TODO add SoftLocker
-  //SoftLocker lock(mutexProcessDList);
-  //if (!lock.IsOk()) //mutex is busy
-  if (0)
+  SoftLocker lock(&mutexProcessDList);
+  if (!lock.IsOk()) //mutex is busy
   {
     if (!fullscreen)
       drawNoFullscreenMessage();