aboutsummaryrefslogtreecommitdiff
path: root/common/system.h
diff options
context:
space:
mode:
authorMax Horn2004-03-15 01:52:07 +0000
committerMax Horn2004-03-15 01:52:07 +0000
commitaf80eef70e4f6ec3585425a9e0b8f3614cbbd57f (patch)
treef89741d681c5447556f66e8d6bf155bbbc66b6fa /common/system.h
parent2314cdf03635deb54e1b93eba32a914227f262d9 (diff)
downloadscummvm-rg350-af80eef70e4f6ec3585425a9e0b8f3614cbbd57f.tar.gz
scummvm-rg350-af80eef70e4f6ec3585425a9e0b8f3614cbbd57f.tar.bz2
scummvm-rg350-af80eef70e4f6ec3585425a9e0b8f3614cbbd57f.zip
fix circular header dependency, by moving StackLock class to common/system.h (it ties closely into OSystem anyway)
svn-id: r13292
Diffstat (limited to 'common/system.h')
-rw-r--r--common/system.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/common/system.h b/common/system.h
index 3afe519617..3ddf4982d7 100644
--- a/common/system.h
+++ b/common/system.h
@@ -25,6 +25,8 @@
#include "common/scummsys.h"
#include "common/savefile.h"
+#include "common/util.h"
+#include "common/rect.h"
/**
@@ -479,7 +481,19 @@ public:
- /** @name Mutex handling */
+ /**
+ * @name Mutex handling
+ * Historically, the OSystem API used to have a method which allowed
+ * creating threads. Hence mutex support was needed for thread syncing.
+ * To ease portability, though, we decided to remove the threading API.
+ * Instead, we now use timers (see setTimerCallback() and Common::Timer).
+ * But since those may be implemented using threads (and in fact, that's
+ * how our primary backend, the SDL one, does it on many systems), we
+ * still have to do mutex syncing in our timer callbacks.
+ *
+ * Hence backends which do not use threads to implement the timers simply
+ * can use dummy implementations for these methods.
+ */
//@{
typedef struct Mutex *MutexRef;
@@ -570,5 +584,24 @@ public:
/** The global OSystem instance. Inited in main(). */
#define g_system (OSystem::instance())
+namespace Common {
+
+/**
+ * Auxillary class to (un)lock a mutex on the stack.
+ */
+class StackLock {
+ OSystem::MutexRef _mutex;
+ OSystem *_syst;
+ const char *_mutexName;
+
+ void lock();
+ void unlock();
+public:
+ StackLock(OSystem::MutexRef mutex, OSystem *syst = 0, const char *mutexName = NULL);
+ ~StackLock();
+};
+
+} // End of namespace Common
+
#endif