[Scummvm-cvs-logs] CVS: scummvm/common timer.h,1.7,1.8 util.cpp,1.14,1.15 util.h,1.20,1.21
Max Horn
fingolfin at users.sourceforge.net
Sat Jul 5 08:20:05 CEST 2003
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv22270/common
Modified Files:
timer.h util.cpp util.h
Log Message:
updated code to use type MutexRef; added class StackLock (from sdl backend, now in util.*)
Index: timer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/timer.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- timer.h 3 Jul 2003 11:18:07 -0000 1.7
+++ timer.h 5 Jul 2003 15:19:11 -0000 1.8
@@ -36,7 +36,7 @@
private:
Engine *_engine;
- void *_mutex;
+ OSystem::MutexRef _mutex;
void *_timerHandler;
int32 _thisTime;
int32 _lastTime;
Index: util.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/util.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- util.cpp 21 May 2003 16:56:45 -0000 1.14
+++ util.cpp 5 Jul 2003 15:19:11 -0000 1.15
@@ -19,6 +19,7 @@
*/
#include "stdafx.h"
+#include "engine.h"
#include "util.h"
//
@@ -163,5 +164,23 @@
uint RandomSource::getRandomNumberRng(uint min, uint max) {
return getRandomNumber(max - min) + min;
+}
+
+StackLock::StackLock(OSystem::MutexRef mutex) : _mutex(mutex) {
+ lock();
+}
+
+StackLock::~StackLock() {
+ unlock();
+}
+
+void StackLock::lock() {
+ assert(g_system);
+ g_system->lock_mutex(_mutex);
+}
+
+void StackLock::unlock() {
+ assert(g_system);
+ g_system->unlock_mutex(_mutex);
}
Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/util.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- util.h 14 Jun 2003 18:15:14 -0000 1.20
+++ util.h 5 Jul 2003 15:19:11 -0000 1.21
@@ -22,6 +22,7 @@
#define COMMON_UTIL_H
#include "scummsys.h"
+#include "system.h"
template<typename T> inline T ABS (T x) { return (x>=0) ? x : -x; }
template<typename T> inline T MIN (T a, T b) { return (a<b) ? a : b; }
@@ -73,5 +74,18 @@
*/
uint getRandomNumberRng(uint min, uint max);
};
+
+/**
+ * Auxillary class to (un)lock a mutex on the stack.
+ */
+class StackLock {
+ OSystem::MutexRef _mutex;
+ void lock();
+ void unlock();
+public:
+ StackLock(OSystem::MutexRef mutex);
+ ~StackLock();
+};
+
#endif
More information about the Scummvm-git-logs
mailing list