changeset 178:0e266fa2510f

* pthread_mutex -> QMutex
author Chris Cannam
date Thu, 05 Oct 2006 11:02:05 +0000
parents aff66ec5aea4
children 0ed2b2e26b44
files base/Scavenger.h
diffstat 1 files changed, 6 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/base/Scavenger.h	Wed Oct 04 11:01:39 2006 +0000
+++ b/base/Scavenger.h	Thu Oct 05 11:02:05 2006 +0000
@@ -27,7 +27,7 @@
 #include <vector>
 #include <list>
 #include <sys/time.h>
-#include <pthread.h>
+#include <QMutex>
 #include <iostream>
 
 /**
@@ -69,7 +69,7 @@
     typedef std::list<T *> ObjectList;
     ObjectList m_excess;
     int m_lastExcess;
-    pthread_mutex_t m_excessMutex;
+    QMutex m_excessMutex;
     void pushExcess(T *);
     void clearExcess(int);
 
@@ -100,7 +100,6 @@
     m_claimed(0),
     m_scavenged(0)
 {
-    pthread_mutex_init(&m_excessMutex, NULL);
 }
 
 template <typename T>
@@ -119,8 +118,6 @@
     }
 
     clearExcess(0);
-
-    pthread_mutex_destroy(&m_excessMutex);
 }
 
 template <typename T>
@@ -180,26 +177,26 @@
 void
 Scavenger<T>::pushExcess(T *t)
 {
-    pthread_mutex_lock(&m_excessMutex);
+    m_excessMutex.lock();
     m_excess.push_back(t);
     struct timeval tv;
     (void)gettimeofday(&tv, 0);
     m_lastExcess = tv.tv_sec;
-    pthread_mutex_unlock(&m_excessMutex);
+    m_excessMutex.unlock();
 }
 
 template <typename T>
 void
 Scavenger<T>::clearExcess(int sec)
 {
-    pthread_mutex_lock(&m_excessMutex);
+    m_excessMutex.lock();
     for (typename ObjectList::iterator i = m_excess.begin();
 	 i != m_excess.end(); ++i) {
 	delete *i;
     }
     m_excess.clear();
     m_lastExcess = sec;
-    pthread_mutex_unlock(&m_excessMutex);
+    m_excessMutex.unlock();
 }
 
 #endif