TrueMutexImpl

This commit is contained in:
David Rose 2009-06-16 00:04:13 +00:00
parent d476b6e55e
commit a1df809fd0
3 changed files with 39 additions and 0 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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;
};