diff options
author | Adam Reichold <adamreichold@myopera.com> | 2013-04-06 18:25:21 +0200 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2013-04-06 18:25:21 +0200 |
commit | a65a4e6f878ff033b780b2f1e3362f2918c93b6b (patch) | |
tree | d9eb79449a56c969193c5713414804be61a1789f | |
parent | 73ff5ad58cfe7ec9415cc1459b6ca083fee608f4 (diff) |
No need to keep the mutex attributes around all the time
-rw-r--r-- | goo/GooMutex.h | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/goo/GooMutex.h b/goo/GooMutex.h index 4d425a29..e9d5a543 100644 --- a/goo/GooMutex.h +++ b/goo/GooMutex.h @@ -18,6 +18,7 @@ // Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2013 Adam Reichold <adamreichold@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 |