From 5e2237dcb0eed993f074f2b17b9cf4bf146761bd Mon Sep 17 00:00:00 2001 From: syntheticpp Date: Sun, 1 Jul 2007 18:14:46 +0000 Subject: [PATCH] add possibility to enable recursive mutex support for pthread git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@828 7ec92016-0320-0410-acc4-a06ded1c099a --- CHANGES | 17 ++++++++++------- include/loki/Threads.h | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index b7d6bd9..1f6040f 100644 --- a/CHANGES +++ b/CHANGES @@ -5,11 +5,14 @@ Version 0.1.7 _____________________________________ General: - - Fixed makefiles for GNU/kFreeBSD, GNU/hurd (lf) - - Fixed build errors with gcc 4.3 pre-release (lf) - - Fixed compiler error that occurs when using 64 bit pointers (rs) - - Added more unit tests (rs) - - Several other bug fixes (rs, pk) + - Fixed makefiles for GNU/kFreeBSD, GNU/hurd (lf) + - Fixed build errors with gcc 4.3 pre-release (lf) + - Fixed compiler error that occurs when using 64 bit pointers (rs) + - Added more unit tests (rs) + - Several other bug fixes (rs, pk) + +Threads: + - add possibility to enable recursive mutex support for pthread (pk) CVS commits by Lukas Fittl (lf), Peter Kümmel (pk), Rich Sposato (rs) @@ -20,8 +23,8 @@ February 25, 2007 _____________________________________ General: - - CacheFactory added by Guillaume Chatelet - - Factory documentation improved by Guillaume Chatelet + - CacheFactory added by Guillaume Chatelet + - Factory documentation improved by Guillaume Chatelet - migrated to subversion (pk) - Mac linker errors fixed (lf) - Makefiles can now be called from sub directories (lf) diff --git a/include/loki/Threads.h b/include/loki/Threads.h index 2c4375e..434c946 100644 --- a/include/loki/Threads.h +++ b/include/loki/Threads.h @@ -89,6 +89,7 @@ #define LOKI_THREADS_MUTEX_LOCK(x) ::EnterCriticalSection (x) #define LOKI_THREADS_MUTEX_UNLOCK(x) ::LeaveCriticalSection (x) #define LOKI_THREADS_LONG LONG +#define LOKI_THREADS_MUTEX_CTOR(x) #define LOKI_THREADS_ATOMIC_FUNCTIONS \ static IntType AtomicIncrement(volatile IntType& lval) \ @@ -110,9 +111,17 @@ #define LOKI_THREADS_MUTEX(x) pthread_mutex_t (x); -// no recursive mutex support #define LOKI_THREADS_MUTEX_INIT(x) ::pthread_mutex_init(x, 0) +// define to 1 to enable recursive mutex support +#if 0 +// experimental recursive mutex support +#define LOKI_THREADS_MUTEX_CTOR(x) : x(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) +#else +// no recursive mutex support +#define LOKI_THREADS_MUTEX_CTOR(x) +#endif + #define LOKI_THREADS_MUTEX_DELETE(x) ::pthread_mutex_destroy (x) #define LOKI_THREADS_MUTEX_LOCK(x) ::pthread_mutex_lock (x) #define LOKI_THREADS_MUTEX_UNLOCK(x) ::pthread_mutex_unlock (x) @@ -147,6 +156,7 @@ #define LOKI_THREADS_MUTEX_LOCK(x) #define LOKI_THREADS_MUTEX_UNLOCK(x) #define LOKI_THREADS_LONG +#define LOKI_THREADS_MUTEX_CTOR(x) #endif @@ -165,7 +175,7 @@ namespace Loki class Mutex { public: - Mutex() + Mutex() LOKI_THREADS_MUTEX_CTOR(mtx_) { LOKI_THREADS_MUTEX_INIT(&mtx_); }