Riley Labrecque avatar Riley Labrecque committed 2f285be

Replaced pthread with SDL_sem

Comments (0)

Files changed (3)

src/Glide64/Gfx #1.3.h

 #include "m64p.h"
 
 #include <stdio.h>
-#include <pthread.h>
+#include <SDL_mutex.h>
 #include <fstream>
 #include <stdlib.h>
 #include <stddef.h>		// offsetof
 extern int evoodoo;
 extern int ev_fullscreen;
 
-extern pthread_mutex_t mutexProcessDList;
+extern SDL_sem *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;
+SDL_sem *mutexProcessDList = SDL_CreateSemaphore(1);
 
 // SOME FUNCTION DEFINITIONS 
 

src/Glide64/rdp.cpp

 //****************************************************************
 
 #include <math.h>
-#include <pthread.h>
 #include "Gfx #1.3.h"
 #include "m64p.h"
 #include "Ini.h"
 {
 public:
   // lock the mutex in the ctor
-  SoftLocker(pthread_mutex_t *mutex)
+  SoftLocker(SDL_sem *mutex)
     : _isOk(false), _mutex(mutex)
-  { _isOk = ( pthread_mutex_trylock(_mutex) == 0 ); }
+  { _isOk = ( SDL_SemTryWait(_mutex) == 0 ); }
 
   // returns true if mutex was successfully locked in ctor
   bool IsOk() const
 
   // unlock the mutex in dtor
   ~SoftLocker()
-  { if ( IsOk() ) pthread_mutex_unlock(_mutex); }
+  { if ( IsOk() ) SDL_SemPost(_mutex); }
 
 private:
   bool     _isOk;
-  pthread_mutex_t *_mutex;
+  SDL_sem *_mutex;
 };
 
 
 
 EXPORT void CALL ProcessDList(void)
 {
-  SoftLocker lock(&mutexProcessDList);
+  SoftLocker lock(mutexProcessDList);
   if (!lock.IsOk()) //mutex is busy
   {
     if (!fullscreen)
   LOG ("ProcessRDPList ()\n");
   LRDP("ProcessRDPList ()\n");
 
-  SoftLocker lock(&mutexProcessDList);
+  SoftLocker lock(mutexProcessDList);
   if (!lock.IsOk()) //mutex is busy
   {
     if (!fullscreen)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.