added some thread safty ... much more still needed
[physics.git] / src / debug.cpp
index c155785..909a54f 100644 (file)
@@ -22,11 +22,31 @@ using std::cerr;
 using std::cout;
 using std::endl;
 
+#include <SDL/SDL.h>
+
 /// ***** Public Methods *****
 
+SDL_mutex* muDPF = NULL;
+
 void DPF(int level, const char* pstr)
 {
-  cout << pstr << endl;
+    // lock
+    SDL_mutexP( muDPF );
+
+    cout << pstr << endl;
+
+    //unlock
+    SDL_mutexV( muDPF );
+}
+
+void debug::init()
+{
+    muDPF = SDL_CreateMutex();
+}
+
+void debug::clean()
+{
+    SDL_DestroyMutex( muDPF );
 }
 
 /// ***** Private Methods *****