Browse Source

forgot to check this in

David Rose 14 years ago
parent
commit
f63bf2526a
2 changed files with 20 additions and 0 deletions
  1. 19 0
      panda/src/pipeline/mutexHolder.I
  2. 1 0
      panda/src/pipeline/mutexHolder.h

+ 19 - 0
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

+ 1 - 0
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: