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
This commit is contained in:
syntheticpp 2007-07-01 18:14:46 +00:00
parent b2ad60ebe7
commit 5e2237dcb0
2 changed files with 22 additions and 9 deletions

View file

@ -11,6 +11,9 @@ General:
- Added more unit tests (rs) - Added more unit tests (rs)
- Several other bug fixes (rs, pk) - 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) CVS commits by Lukas Fittl (lf), Peter Kümmel (pk), Rich Sposato (rs)
_____________________________________ _____________________________________

View file

@ -89,6 +89,7 @@
#define LOKI_THREADS_MUTEX_LOCK(x) ::EnterCriticalSection (x) #define LOKI_THREADS_MUTEX_LOCK(x) ::EnterCriticalSection (x)
#define LOKI_THREADS_MUTEX_UNLOCK(x) ::LeaveCriticalSection (x) #define LOKI_THREADS_MUTEX_UNLOCK(x) ::LeaveCriticalSection (x)
#define LOKI_THREADS_LONG LONG #define LOKI_THREADS_LONG LONG
#define LOKI_THREADS_MUTEX_CTOR(x)
#define LOKI_THREADS_ATOMIC_FUNCTIONS \ #define LOKI_THREADS_ATOMIC_FUNCTIONS \
static IntType AtomicIncrement(volatile IntType& lval) \ static IntType AtomicIncrement(volatile IntType& lval) \
@ -110,9 +111,17 @@
#define LOKI_THREADS_MUTEX(x) pthread_mutex_t (x); #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 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_DELETE(x) ::pthread_mutex_destroy (x)
#define LOKI_THREADS_MUTEX_LOCK(x) ::pthread_mutex_lock (x) #define LOKI_THREADS_MUTEX_LOCK(x) ::pthread_mutex_lock (x)
#define LOKI_THREADS_MUTEX_UNLOCK(x) ::pthread_mutex_unlock (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_LOCK(x)
#define LOKI_THREADS_MUTEX_UNLOCK(x) #define LOKI_THREADS_MUTEX_UNLOCK(x)
#define LOKI_THREADS_LONG #define LOKI_THREADS_LONG
#define LOKI_THREADS_MUTEX_CTOR(x)
#endif #endif
@ -165,7 +175,7 @@ namespace Loki
class Mutex class Mutex
{ {
public: public:
Mutex() Mutex() LOKI_THREADS_MUTEX_CTOR(mtx_)
{ {
LOKI_THREADS_MUTEX_INIT(&mtx_); LOKI_THREADS_MUTEX_INIT(&mtx_);
} }