diff options
author | James Brown | 2004-02-14 08:56:26 +0000 |
---|---|---|
committer | James Brown | 2004-02-14 08:56:26 +0000 |
commit | 5ee96b4625a2bfa64ba2b06dc37527bf3238d851 (patch) | |
tree | 3c064602f07818996b135304a32bf9ce858e4cdf /common | |
parent | 6731606837debcc5aafa8b1680db9dae4a3e5887 (diff) | |
download | scummvm-rg350-5ee96b4625a2bfa64ba2b06dc37527bf3238d851.tar.gz scummvm-rg350-5ee96b4625a2bfa64ba2b06dc37527bf3238d851.tar.bz2 scummvm-rg350-5ee96b4625a2bfa64ba2b06dc37527bf3238d851.zip |
Add mutex tracking to make it easier to debug imuse deadlocks
svn-id: r12870
Diffstat (limited to 'common')
-rw-r--r-- | common/util.cpp | 10 | ||||
-rw-r--r-- | common/util.h | 4 |
2 files changed, 11 insertions, 3 deletions
diff --git a/common/util.cpp b/common/util.cpp index 962f3d9afd..601894883d 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -103,8 +103,8 @@ uint RandomSource::getRandomNumberRng(uint min, uint max) { #pragma mark - -StackLock::StackLock(OSystem::MutexRef mutex, OSystem *syst) - : _mutex(mutex), _syst(syst) { +StackLock::StackLock(OSystem::MutexRef mutex, OSystem *syst, char *mutexName) + : _mutex(mutex), _syst(syst), _mutexName(mutexName) { if (syst == 0) _syst = g_system; lock(); @@ -116,11 +116,17 @@ StackLock::~StackLock() { void StackLock::lock() { assert(_syst); + if (_mutexName != NULL) + debug(5, "Locking mutex %s", _mutexName); + _syst->lock_mutex(_mutex); } void StackLock::unlock() { assert(_syst); + if (_mutexName != NULL) + debug(5, "Unlocking mutex %s", _mutexName); + _syst->unlock_mutex(_mutex); } diff --git a/common/util.h b/common/util.h index 7b91104523..e05cc12c71 100644 --- a/common/util.h +++ b/common/util.h @@ -81,10 +81,12 @@ public: class StackLock { OSystem::MutexRef _mutex; OSystem *_syst; + char *_mutexName; + void lock(); void unlock(); public: - StackLock(OSystem::MutexRef mutex, OSystem *syst = 0); + StackLock(OSystem::MutexRef mutex, OSystem *syst = 0, char *mutexName = NULL); ~StackLock(); }; |