From: ghost Date: Thu, 17 Dec 2009 13:46:04 +0000 (+0100) Subject: elock.h: add possibility to create recursive mutexes X-Git-Tag: 2.7.0~24^2~1^2~1 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/5e05afa7dbc5acfc92a158dcc88b0be12c52af62 elock.h: add possibility to create recursive mutexes --- diff --git a/lib/base/elock.h b/lib/base/elock.h index 51582e67..01757182 100644 --- a/lib/base/elock.h +++ b/lib/base/elock.h @@ -83,9 +83,18 @@ class eSingleLock pthread_mutex_t m_lock; eSingleLock(eSingleLock &); public: - eSingleLock() + eSingleLock(bool recursive=false) { - pthread_mutex_init(&m_lock, 0); + if (recursive) + { + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&m_lock, &attr); + pthread_mutexattr_destroy(&attr); + } + else + pthread_mutex_init(&m_lock, 0); } ~eSingleLock() {