aboutsummaryrefslogtreecommitdiff
path: root/common/system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/system.cpp')
-rw-r--r--common/system.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/common/system.cpp b/common/system.cpp
index ef41f7c234..ce9ba67c3c 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -83,3 +83,37 @@ bool OSystem::setGraphicsMode(const char *name) {
return false;
}
+
+#pragma mark -
+
+
+namespace Common {
+
+StackLock::StackLock(OSystem::MutexRef mutex, OSystem *syst, const char *mutexName)
+ : _mutex(mutex), _syst(syst), _mutexName(mutexName) {
+ if (syst == 0)
+ _syst = g_system;
+ lock();
+}
+
+StackLock::~StackLock() {
+ unlock();
+}
+
+void StackLock::lock() {
+ assert(_syst);
+ if (_mutexName != NULL)
+ debug(6, "Locking mutex %s", _mutexName);
+
+ _syst->lockMutex(_mutex);
+}
+
+void StackLock::unlock() {
+ assert(_syst);
+ if (_mutexName != NULL)
+ debug(6, "Unlocking mutex %s", _mutexName);
+
+ _syst->unlockMutex(_mutex);
+}
+
+} // End of namespace Common