png img proxy fixes, speed zoom segv fix, colapse ins 1frm silence undo, repair rende...
[goodguy/history.git] / cinelerra-5.1 / guicast / mutex.C
index 6bbf279e78396f033460a1a8cfd20a3f150e3561..6ac188d5e2c7222f1d3af68c02430ff2c6cfeba1 100644 (file)
  */
 
 #include <stdio.h>
+#include <string.h>
 #include <errno.h>
 
-#ifndef NO_GUICAST
 #include "bcsignals.h"
-#endif
 #include "mutex.h"
 
 
 Mutex::Mutex(const char *title, int recursive)
 {
        this->title = title;
+       this->trace = 0;
        pthread_mutexattr_t attr;
        pthread_mutexattr_init(&attr);
        pthread_mutex_init(&mutex, &attr);
@@ -45,9 +45,7 @@ Mutex::~Mutex()
 {
        pthread_mutex_destroy(&mutex);
        pthread_mutex_destroy(&recursive_lock);
-#ifndef NO_GUICAST
        UNSET_ALL_LOCKS(this);
-#endif
 }
 
 int Mutex::lock(const char *location)
@@ -66,9 +64,7 @@ int Mutex::lock(const char *location)
        }
 
 
-#ifndef NO_GUICAST
        SET_LOCK(this, title, location);
-#endif
        if(pthread_mutex_lock(&mutex)) perror("Mutex::lock");
 
 
@@ -88,9 +84,7 @@ int Mutex::lock(const char *location)
        }
 
 
-#ifndef NO_GUICAST
        SET_LOCK2
-#endif
        return 0;
 }
 
@@ -120,11 +114,10 @@ int Mutex::unlock()
                count = 0;
 
 
-#ifndef NO_GUICAST
        UNSET_LOCK(this);
-#endif
 
-       if(pthread_mutex_unlock(&mutex)) perror("Mutex::unlock");
+       int ret = pthread_mutex_unlock(&mutex);
+       if( ret ) fprintf(stderr, "Mutex::unlock: %s\n",strerror(ret));
        return 0;
 }
 
@@ -145,10 +138,8 @@ int Mutex::trylock(const char *location)
        else
                count = 1;
 
-#ifndef NO_GUICAST
        SET_LOCK(this, title, location);
        SET_LOCK2
-#endif
        return 0;
 }
 
@@ -163,11 +154,10 @@ int Mutex::reset()
        pthread_mutexattr_t attr;
        pthread_mutexattr_init(&attr);
        pthread_mutex_init(&mutex, &attr);
+       UNSET_ALL_LOCKS(this)
+       trace = 0;
        count = 0;
        thread_id = 0;
        thread_id_valid = 0;
-#ifndef NO_GUICAST
-       UNSET_ALL_LOCKS(this)
-#endif
        return 0;
 }