[poppler] goo/GooMutex.h

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Apr 6 09:25:36 PDT 2013


 goo/GooMutex.h |   27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

New commits:
commit a65a4e6f878ff033b780b2f1e3362f2918c93b6b
Author: Adam Reichold <adamreichold at myopera.com>
Date:   Sat Apr 6 18:25:21 2013 +0200

    No need to keep the mutex attributes around all the time

diff --git a/goo/GooMutex.h b/goo/GooMutex.h
index 4d425a2..e9d5a54 100644
--- a/goo/GooMutex.h
+++ b/goo/GooMutex.h
@@ -18,6 +18,7 @@
 // Copyright (C) 2009 Kovid Goyal <kovid at kovidgoyal.net>
 // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2013 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2013 Adam Reichold <adamreichold at myopera.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -53,26 +54,18 @@ typedef CRITICAL_SECTION GooMutex;
 
 #include <pthread.h>
 
-typedef struct {
-  pthread_mutexattr_t attributes;
-  pthread_mutex_t mutex;
-} GooMutex;
+typedef pthread_mutex_t GooMutex;
 
 inline void gInitMutex(GooMutex *m) {
-  pthread_mutexattr_init(&m->attributes);
-  pthread_mutexattr_settype(&m->attributes, PTHREAD_MUTEX_RECURSIVE);
-  pthread_mutex_init(&m->mutex, &m->attributes);
-}
-inline void gDestroyMutex(GooMutex *m) {
-  pthread_mutex_destroy(&m->mutex);
-  pthread_mutexattr_destroy(&m->attributes);
-}
-inline void gLockMutex(GooMutex *m) {
-  pthread_mutex_lock(&m->mutex);
-}
-inline void gUnlockMutex(GooMutex *m) {
-  pthread_mutex_unlock(&m->mutex);
+  pthread_mutexattr_t mutexattr;
+  pthread_mutexattr_init(&mutexattr);
+  pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
+  pthread_mutex_init(m, &mutexattr);
+  pthread_mutexattr_destroy(&mutexattr);
 }
+#define gDestroyMutex(m) pthread_mutex_destroy(m)
+#define gLockMutex(m) pthread_mutex_lock(m)
+#define gUnlockMutex(m) pthread_mutex_unlock(m)
 
 #endif
 


More information about the poppler mailing list