Browse Source

TrueMutexImpl

David Rose 16 years ago
parent
commit
a1df809fd0

+ 15 - 0
dtool/src/dtoolbase/mutexImpl.h

@@ -47,6 +47,21 @@ typedef ReMutexPosixImpl ReMutexImpl;
 
 #endif
 
+// Also define what a true OS-provided lock will be, even if we don't
+// have threading enabled in the build.  Sometimes we need to
+// interface with an external program or something that wants real
+// locks.
+#if defined(WIN32_VC)
+typedef MutexWin32Impl TrueMutexImpl;
+
+#elif defined(HAVE_POSIX_THREADS)
+typedef MutexPosixImpl TrueMutexImpl;
+
+#else
+// No true threads, sorry.  Better not try to use 'em.
+
+#endif
+
 #endif
 
 

+ 20 - 0
dtool/src/dtoolbase/mutexPosixImpl.I

@@ -78,6 +78,16 @@ release() {
   assert(result == 0);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: MutexPosixImpl::get_posix_lock
+//       Access: Public
+//  Description: Returns the underlying Posix lock handle.
+////////////////////////////////////////////////////////////////////
+INLINE pthread_mutex_t *MutexPosixImpl::
+get_posix_lock() {
+  return _lock;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: ReMutexPosixImpl::Constructor
 //       Access: Public
@@ -142,3 +152,13 @@ release() {
   int result = pthread_mutex_unlock(&_lock);
   assert(result == 0);
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: ReMutexPosixImpl::get_posix_lock
+//       Access: Public
+//  Description: Returns the underlying Posix lock handle.
+////////////////////////////////////////////////////////////////////
+INLINE pthread_mutex_t *ReMutexPosixImpl::
+get_posix_lock() {
+  return _lock;
+}

+ 4 - 0
dtool/src/dtoolbase/mutexPosixImpl.h

@@ -37,6 +37,8 @@ public:
   INLINE bool try_acquire();
   INLINE void release();
 
+  INLINE pthread_mutex_t *get_posix_lock();
+
 private:
   pthread_mutex_t _lock;
   friend class ConditionVarPosixImpl;
@@ -55,6 +57,8 @@ public:
   INLINE bool try_acquire();
   INLINE void release();
 
+  INLINE pthread_mutex_t *get_posix_lock();
+
 private:
   pthread_mutex_t _lock;
 };