From f63bf2526a4e1c5630d3f850346321e9186ee5c9 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 2 Sep 2011 23:09:18 +0000 Subject: [PATCH] forgot to check this in --- panda/src/pipeline/mutexHolder.I | 19 +++++++++++++++++++ panda/src/pipeline/mutexHolder.h | 1 + 2 files changed, 20 insertions(+) diff --git a/panda/src/pipeline/mutexHolder.I b/panda/src/pipeline/mutexHolder.I index e8ecf59e26..560add49ab 100644 --- a/panda/src/pipeline/mutexHolder.I +++ b/panda/src/pipeline/mutexHolder.I @@ -26,6 +26,25 @@ MutexHolder(const Mutex &mutex) { #endif } +//////////////////////////////////////////////////////////////////// +// Function: MutexHolder::Constructor +// Access: Public +// Description: This variant on the constructor accepts the current +// thread as a parameter, if it is already known, as an +// optimization. +//////////////////////////////////////////////////////////////////// +INLINE MutexHolder:: +MutexHolder(const Mutex &mutex, Thread *current_thread) { +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) + _mutex = &mutex; + // Actually, the regular Mutex class doesn't need the current thread + // parameter at the moment. So not actually an optimization. But + // we keep this method because it causes a symmetry with + // ReMutexHolder. + _mutex->acquire(/*current_thread*/); +#endif +} + //////////////////////////////////////////////////////////////////// // Function: MutexHolder::Constructor // Access: Public diff --git a/panda/src/pipeline/mutexHolder.h b/panda/src/pipeline/mutexHolder.h index 5df4b4c38a..1147957ff6 100644 --- a/panda/src/pipeline/mutexHolder.h +++ b/panda/src/pipeline/mutexHolder.h @@ -29,6 +29,7 @@ class EXPCL_PANDA_PIPELINE MutexHolder { public: INLINE MutexHolder(const Mutex &mutex); + INLINE MutexHolder(const Mutex &mutex, Thread *current_thread); INLINE MutexHolder(Mutex *&mutex); INLINE ~MutexHolder(); private: