diff options
| author | ghost <andreas.monzner@multimedia-labs.de> | 2009-12-17 14:46:04 +0100 |
|---|---|---|
| committer | ghost <andreas.monzner@multimedia-labs.de> | 2009-12-17 15:15:20 +0100 |
| commit | 5e05afa7dbc5acfc92a158dcc88b0be12c52af62 (patch) | |
| tree | c5cea2c0bf01bf356fb43f914a1bef7ef1290690 /lib/base | |
| parent | 7b46b591444685733d1fb3af5c814e0a93cf4d5f (diff) | |
| download | enigma2-5e05afa7dbc5acfc92a158dcc88b0be12c52af62.tar.gz enigma2-5e05afa7dbc5acfc92a158dcc88b0be12c52af62.zip | |
elock.h: add possibility to create recursive mutexes
Diffstat (limited to 'lib/base')
| -rw-r--r-- | lib/base/elock.h | 13 |
1 files changed, 11 insertions, 2 deletions
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() { |
