From 97f794be0e0b150641de81b3e3f0c616b7efd48d Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 7 Jun 2007 03:34:08 +0000 Subject: [PATCH] attempt to protect paranoid_clock from multithread --- panda/src/express/trueClock.cxx | 5 +++++ panda/src/express/trueClock.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/panda/src/express/trueClock.cxx b/panda/src/express/trueClock.cxx index e8b43f86e8..e17234a99b 100644 --- a/panda/src/express/trueClock.cxx +++ b/panda/src/express/trueClock.cxx @@ -94,6 +94,10 @@ double TrueClock:: get_short_time() { double time; + if (_paranoid_clock) { + _lock.lock(); + } + if (_has_high_res) { // Use the high-resolution clock. This is of questionable value, // since (a) on some OS's and hardware, the low 24 bits can @@ -123,6 +127,7 @@ get_short_time() { // Check for rollforwards, rollbacks, and compensate for Speed // Gear type programs by verifying against the time of day clock. time = correct_time(time); + _lock.release(); } return time; diff --git a/panda/src/express/trueClock.h b/panda/src/express/trueClock.h index d1691b454d..cbb98eeec7 100644 --- a/panda/src/express/trueClock.h +++ b/panda/src/express/trueClock.h @@ -22,6 +22,7 @@ #include "pandabase.h" #include "typedef.h" #include "pdeque.h" +#include "mutexImpl.h" //////////////////////////////////////////////////////////////////// // Class : TrueClock @@ -100,6 +101,7 @@ protected: CC_speed_up, }; ChaseClock _chase_clock; + MutexImpl _lock; #endif // WIN32 };