libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] libcvd/cvd/internal aligned_mem.h


From: Edward Rosten
Subject: [libcvd-members] libcvd/cvd/internal aligned_mem.h
Date: Wed, 19 Jul 2006 17:00:02 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    libcvd
Changes by:     Edward Rosten <edrosten>        06/07/19 17:00:02

Modified files:
        cvd/internal   : aligned_mem.h 

Log message:
        Now uses CVD::Synchronized.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/internal/aligned_mem.h?cvsroot=libcvd&r1=1.7&r2=1.8

Patches:
Index: aligned_mem.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/internal/aligned_mem.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- aligned_mem.h       19 Jul 2006 00:12:10 -0000      1.7
+++ aligned_mem.h       19 Jul 2006 17:00:01 -0000      1.8
@@ -8,7 +8,7 @@
     #ifndef CVD_HAVE_PTHREAD
        #error "CVD is not compiled with thread support. This code is not 
thread safe."
     #else 
-       #include <pthread.h>
+       #include <cvd/synchronized.h>
     #endif
 #endif
 
@@ -55,7 +55,9 @@
        };
        static std::map<T*, entry> buffers;
 
-       static pthread_mutex_t mutex;
+       #if defined(CVD_HAVE_PTHREAD) && defined(_REENTRANT)
+           static Synchronized mutex;
+       #endif
 
 
        static T* alloc(size_t count)
@@ -67,21 +69,18 @@
 
 
            #if defined(CVD_HAVE_PTHREAD) && defined(_REENTRANT)
-           pthread_mutex_lock(&mutex);
+           Lock lock(mutex);
            #endif
 
            buffers[astart] = e;
 
-           #if defined(CVD_HAVE_PTHREAD) && defined(_REENTRANT)
-           pthread_mutex_unlock(&mutex);
-           #endif
-
            return astart;
        }
+
        static void release(T* ptr) 
        {
            #if defined(CVD_HAVE_PTHREAD) && defined(_REENTRANT)
-           pthread_mutex_lock(&mutex);
+           Lock lock(mutex);
            #endif
 
            typename std::map<T*,entry>::iterator it = buffers.find(ptr);
@@ -91,18 +90,12 @@
 
 
            buffers.erase(it);
-
-           #if defined(CVD_HAVE_PTHREAD) && defined(_REENTRANT)
-           pthread_mutex_unlock(&mutex);
-           #endif
        }
     };
-
-    template<class T, int N> pthread_mutex_t aligned_mem<T,N>::mutex = 
PTHREAD_MUTEX_INITIALIZER;
+    template<class T, int N> Synchronized aligned_mem<T,N>::mutex;
 
     template <class T, int N> std::map<T*,typename aligned_mem<T,N>::entry> 
aligned_mem<T,N>::buffers;
 
-
   }
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]