summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-24 22:06:31 +0000
committernw1 <nw1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-24 22:06:31 +0000
commit3364a7e4a47c1c9f82bf143a8364d2e6dba9277d (patch)
treec28955d3a4f333b38f8b0544acf941b9941525b3
parentba8a6fdf2c36527de53d08074a3991dfe810b69f (diff)
downloadATCD-3364a7e4a47c1c9f82bf143a8364d2e6dba9277d.tar.gz
ACE_Thread_Mutex is already recursive on Win32. Let ACE_Recursive_Thread_Mutex take advantage of this.
-rw-r--r--ace/Synch.cpp43
-rw-r--r--ace/Synch.h7
-rw-r--r--ace/Synch.i23
3 files changed, 56 insertions, 17 deletions
diff --git a/ace/Synch.cpp b/ace/Synch.cpp
index da242d98d74..148763e9ccc 100644
--- a/ace/Synch.cpp
+++ b/ace/Synch.cpp
@@ -410,7 +410,6 @@ ACE_Auto_Event::dump (void) const
#if defined (ACE_HAS_THREADS)
-ACE_ALLOC_HOOK_DEFINE(ACE_Recursive_Thread_Mutex)
ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Mutex_Guard)
void
@@ -440,6 +439,31 @@ ACE_Thread_Mutex_Guard::dump (void) const
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
}
+ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex (LPCTSTR name,
+ void *arg)
+#if !defined (ACE_WIN32)
+ : nesting_mutex_ (name, arg),
+ lock_available_ (nesting_mutex_, name, arg),
+ nesting_level_ (0),
+ owner_id_ (ACE_OS::NULL_thread)
+#else /* ACE_WIN32 */
+ : ACE_Thread_Mutex (name, arg)
+#endif /* ACE_WIN32 */
+{
+#if defined (ACE_HAS_FSU_PTHREADS) && ! defined (ACE_WIN32)
+// Initialize FSU pthreads package.
+// If called more than once, pthread_init does nothing
+// and so does no harm.
+ pthread_init ();
+#endif /* ACE_HAS_FSU_PTHREADS && ! ACE_WIN32 */
+// ACE_TRACE ("ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex");
+}
+
+#if !defined (ACE_WIN32)
+ACE_ALLOC_HOOK_DEFINE(ACE_Recursive_Thread_Mutex)
+
+// The counter part of the following two functions for Win32
+// are located in file Synch.i
ACE_thread_t
ACE_Recursive_Thread_Mutex::get_thread_id (void)
{
@@ -461,22 +485,6 @@ ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex (const ACE_Recursive_Thre
{
}
-ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex (LPCTSTR name,
- void *arg)
- : nesting_mutex_ (name, arg),
- lock_available_ (nesting_mutex_, name, arg),
- nesting_level_ (0),
- owner_id_ (ACE_OS::NULL_thread)
-{
-#if defined (ACE_HAS_FSU_PTHREADS)
-// Initialize FSU pthreads package.
-// If called more than once, pthread_init does nothing
-// and so does no harm.
- pthread_init ();
-#endif /* ACE_HAS_FSU_PTHREADS */
-// ACE_TRACE ("ACE_Recursive_Thread_Mutex::ACE_Recursive_Thread_Mutex");
-}
-
ACE_Recursive_Thread_Mutex::~ACE_Recursive_Thread_Mutex (void)
{
// ACE_TRACE ("ACE_Recursive_Thread_Mutex::~ACE_Recursive_Thread_Mutex");
@@ -587,6 +595,7 @@ ACE_Recursive_Thread_Mutex::dump (void) const
#endif /* !ACE_HAS_DCETHREADS */
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
}
+#endif /* ! ACE_WIN32 */
ACE_ALLOC_HOOK_DEFINE(ACE_Condition_Thread_Mutex)
diff --git a/ace/Synch.h b/ace/Synch.h
index ff2c766e843..4801867327e 100644
--- a/ace/Synch.h
+++ b/ace/Synch.h
@@ -1073,6 +1073,9 @@ private:
};
class ACE_Export ACE_Recursive_Thread_Mutex
+#if defined (ACE_WIN32)
+ : public ACE_Thread_Mutex
+#endif /* ACE_WIN32 */
{
// = TITLE
// Implement a C++ wrapper that allows calls to class
@@ -1091,6 +1094,7 @@ public:
void *arg = 0);
// Initialize a recursive mutex.
+#if !defined (ACE_WIN32)
~ACE_Recursive_Thread_Mutex (void);
// Implicitly release a recursive mutex.
@@ -1137,6 +1141,7 @@ public:
// Releases a recursive mutex (will not release mutex until all the
// nesting level drops to 0, which means the mutex is no longer
// held).
+#endif /* ! ACE_WIN32 */
ACE_thread_t get_thread_id (void);
// Return the id of the thread that currently owns the mutex.
@@ -1147,6 +1152,7 @@ public:
// The nesting level is incremented every time the thread acquires
// the mutex recursively.
+#if !defined (ACE_WIN32)
void dump (void) const;
// Dump the state of an object.
@@ -1169,6 +1175,7 @@ protected:
ACE_thread_t owner_id_;
// Current owner of the lock.
+#endif /* ! ACE_WIN32 */
private:
// = Prevent assignment and initialization.
diff --git a/ace/Synch.i b/ace/Synch.i
index 50381619d9f..f08e8ad1104 100644
--- a/ace/Synch.i
+++ b/ace/Synch.i
@@ -513,6 +513,7 @@ ACE_Condition_Thread_Mutex::mutex (void)
return this->mutex_;
}
+#if !defined (ACE_WIN32)
ACE_INLINE int
ACE_Recursive_Thread_Mutex::remove (void)
{
@@ -552,6 +553,28 @@ ACE_Recursive_Thread_Mutex::tryacquire_write (void)
return tryacquire ();
}
+#else /* ACE_WIN32 */
+// The counter part of the following two functions for non-Win32 platforms
+// are located in file Synch.cpp
+ACE_thread_t
+ACE_Recursive_Thread_Mutex::get_thread_id (void)
+{
+ // @@ The structure CriticalSection in Win32 doesn't hold
+ // the thread handle of the thread that owns the lock. However
+ // it is still not clear at this point how to translate a
+ // thread handle to its corresponding thread id.
+ errno = ENOTSUP;
+ return ACE_OS::NULL_thread;
+}
+
+int
+ACE_Recursive_Thread_Mutex::get_nesting_level (void)
+{
+ return this->lock_.RecursionCount;
+}
+
+#endif /* ACE_WIN32 */
+
#endif /* ACE_HAS_THREADS */
// Explicitly destroy the mutex.