activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1101057 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent: PlatformThread.h Threading.cpp unix/PlatformThread.cpp windows/PlatformThread.cpp
Date Mon, 09 May 2011 15:18:34 GMT
Author: tabish
Date: Mon May  9 15:18:33 2011
New Revision: 1101057

URL: http://svn.apache.org/viewvc?rev=1101057&view=rev
Log:
Add some more abstractions to allow for platform specific thread handle cleanup

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/PlatformThread.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/PlatformThread.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/PlatformThread.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/PlatformThread.h?rev=1101057&r1=1101056&r2=1101057&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/PlatformThread.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/PlatformThread.h
Mon May  9 15:18:33 2011
@@ -99,12 +99,16 @@ namespace concurrent {
 
         static void detachThread(decaf_thread_t handle);
 
+        static void detachOSThread(decaf_thread_t handle);
+
         static void joinThread(decaf_thread_t handle);
 
         static void exitThread();
 
         static decaf_thread_t getCurrentThread();
 
+        static decaf_thread_t getSafeOSThreadHandle();
+
         static long long getCurrentThreadId();
 
         static int getPriority(decaf_thread_t thread);

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp?rev=1101057&r1=1101056&r2=1101057&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/Threading.cpp
Mon May  9 15:18:33 2011
@@ -805,6 +805,8 @@ void Threading::destroyThread(ThreadHand
 
     if (!thread->osThread) {
         Threading::join(thread, 0, 0);
+    } else {
+        PlatformThread::detachOSThread(thread->handle);
     }
     PlatformThread::destroyMutex(thread->mutex);
     PlatformThread::destroyCondition(thread->condition);

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp?rev=1101057&r1=1101056&r2=1101057&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/PlatformThread.cpp
Mon May  9 15:18:33 2011
@@ -299,6 +299,11 @@ void PlatformThread::detachThread(decaf_
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void PlatformThread::detachOSThread(decaf_thread_t handle DECAF_UNUSED) {
+    // Nothing to do on Linux.
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void PlatformThread::joinThread(decaf_thread_t handle) {
     void* theReturn = 0;
     pthread_join(handle, &theReturn);
@@ -316,6 +321,11 @@ decaf_thread_t PlatformThread::getCurren
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+decaf_thread_t PlatformThread::getSafeOSThreadHandle() {
+    return pthread_self();
+}
+
+////////////////////////////////////////////////////////////////////////////////
 long long PlatformThread::getCurrentThreadId() {
 
     // pthread_t can be an int or struct or who knows so we use the address

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/PlatformThread.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/PlatformThread.cpp?rev=1101057&r1=1101056&r2=1101057&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/PlatformThread.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/PlatformThread.cpp
Mon May  9 15:18:33 2011
@@ -204,6 +204,11 @@ void PlatformThread::detachThread(decaf_
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void PlatformThread::detachOSThread(decaf_thread_t handle) {
+    ::CloseHandle(handle);
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void PlatformThread::joinThread(decaf_thread_t handle) {
     ::WaitForSingleObject(handle, INFINITE);
 }
@@ -219,6 +224,17 @@ decaf_thread_t PlatformThread::getCurren
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+decaf_thread_t PlatformThread::getSafeOSThreadHandle() {
+
+    decaf_thread_t value;
+
+    ::DuplicateHandle(::GetCurrentProcess(), ::GetCurrentThread(),
+                      ::GetCurrentProcess(), &value, 0, TRUE, DUPLICATE_SAME_ACCESS);
+
+    return value;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 long long PlatformThread::getCurrentThreadId() {
     return ::GetCurrentThreadId();
 }



Mime
View raw message