Refactored the ReentrantMutex support so that it utilises the underling thread implementation for recusive mutex support.

This commit is contained in:
Robert Osfield
2010-02-18 20:14:41 +00:00
parent ab66740fb0
commit 787daeeb93
5 changed files with 33 additions and 100 deletions

View File

@@ -30,17 +30,25 @@ using namespace OpenThreads;
//
// Use: public.
//
Mutex::Mutex() {
Mutex::Mutex(MutexType type):
_mutexType(type)
{
pthread_mutexattr_t mutex_attr;
pthread_mutexattr_init( &mutex_attr );
PThreadMutexPrivateData *pd = new PThreadMutexPrivateData();
#ifndef __linux__ // (not available until NPTL) [
pthread_mutexattr_settype( &mutex_attr, PTHREAD_MUTEX_ERRORCHECK );
#endif // ] __linux__
if (type==MUTEX_RECURSIVE)
{
pthread_mutexattr_settype( &mutex_attr, PTHREAD_MUTEX_RECURSIVE );
}
else
{
#ifndef __linux__ // (not available until NPTL) [
pthread_mutexattr_settype( &mutex_attr, PTHREAD_MUTEX_ERRORCHECK );
#endif // ] __linux__
}
#ifdef ALLOW_PRIORITY_SCHEDULING // [
#ifdef __sun // [

View File

@@ -34,7 +34,9 @@ using namespace OpenThreads;
//
// Use: public.
//
Mutex::Mutex() {
Mutex::Mutex(MutexType type):
_mutexType(type)
{
SprocMutexPrivateData *pd = new SprocMutexPrivateData();

View File

@@ -81,7 +81,10 @@ static void _S_nsec_sleep(int __log_nsec) {
//
// Use: public.
//
Mutex::Mutex() {
Mutex::Mutex(MutexType type):
_mutexType(type)
)
{
Win32MutexPrivateData *pd = new Win32MutexPrivateData();
_prvData = static_cast<void *>(pd);
}