You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/11/17 23:06:03 UTC

svn commit: r881564 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf: internal/util/concurrent/ internal/util/concurrent/unix/ internal/util/concurrent/windows/ util/concurrent/

Author: tabish
Date: Tue Nov 17 22:06:02 2009
New Revision: 881564

URL: http://svn.apache.org/viewvc?rev=881564&view=rev
Log:
fix possible deletion of incomplete type.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/ConditionImpl.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/MutexImpl.h
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/ConditionImpl.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/MutexImpl.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/ConditionImpl.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/MutexImpl.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/ConditionImpl.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/ConditionImpl.h?rev=881564&r1=881563&r2=881564&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/ConditionImpl.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/ConditionImpl.h Tue Nov 17 22:06:02 2009
@@ -47,6 +47,13 @@
         static decaf::util::concurrent::ConditionHandle* create( decaf::util::concurrent::MutexHandle* mutex );
 
         /**
+         * Destroy a previously create Condition instance.
+         *
+         * @param handle The Condition handle to be destroyed.
+         */
+        static void destroy( decaf::util::concurrent::ConditionHandle* handle );
+
+        /**
          * Waits for the condition to be signaled.
          *
          * @param condition the handle to the condition to wait on.

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/MutexImpl.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/MutexImpl.h?rev=881564&r1=881563&r2=881564&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/MutexImpl.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/MutexImpl.h Tue Nov 17 22:06:02 2009
@@ -46,6 +46,13 @@
         static decaf::util::concurrent::MutexHandle* create();
 
         /**
+         * Destroy a previously create Mutex instance.
+         *
+         * @param mutex The Mutex instance to be destroyed.
+         */
+        static void destroy( decaf::util::concurrent::MutexHandle* handle );
+
+        /**
          * Locks the Mutex.  If the Mutex is already locked by another thread this method
          * blocks until the Mutex becomes unlocked and this thread acquires the lock.
          *

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/ConditionImpl.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/ConditionImpl.cpp?rev=881564&r1=881563&r2=881564&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/ConditionImpl.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/ConditionImpl.cpp Tue Nov 17 22:06:02 2009
@@ -74,6 +74,11 @@
     return handle.release();
 }
 
+////////////////////////////////////////////////////////////////////////////////
+void ConditionImpl::destroy( decaf::util::concurrent::ConditionHandle* handle ) {
+    delete handle;
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 void ConditionImpl::wait( ConditionHandle* condition ) {
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/MutexImpl.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/MutexImpl.cpp?rev=881564&r1=881563&r2=881564&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/MutexImpl.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/unix/MutexImpl.cpp Tue Nov 17 22:06:02 2009
@@ -55,6 +55,11 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void MutexImpl::destroy( decaf::util::concurrent::MutexHandle* handle ) {
+    delete handle;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void MutexImpl::lock( MutexHandle* handle ) {
 
     long long threadId = Thread::getId();

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/ConditionImpl.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/ConditionImpl.cpp?rev=881564&r1=881563&r2=881564&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/ConditionImpl.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/ConditionImpl.cpp Tue Nov 17 22:06:02 2009
@@ -60,6 +60,11 @@
     return handle.release();
 }
 
+////////////////////////////////////////////////////////////////////////////////
+void ConditionImpl::destroy( decaf::util::concurrent::ConditionHandle* handle ) {
+    delete handle;
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 void ConditionImpl::wait( ConditionHandle* condition ) {
 

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/MutexImpl.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/MutexImpl.cpp?rev=881564&r1=881563&r2=881564&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/MutexImpl.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/internal/util/concurrent/windows/MutexImpl.cpp Tue Nov 17 22:06:02 2009
@@ -51,6 +51,11 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+void MutexImpl::destroy( decaf::util::concurrent::MutexHandle* handle ) {
+    delete handle;
+}
+
+////////////////////////////////////////////////////////////////////////////////
 void MutexImpl::lock( MutexHandle* handle ) {
 
     long long threadId = Thread::getId();

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp?rev=881564&r1=881563&r2=881564&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.cpp Tue Nov 17 22:06:02 2009
@@ -21,7 +21,6 @@
 #include <decaf/internal/util/concurrent/ConditionImpl.h>
 
 #include <list>
-#include <memory>
 
 using namespace decaf;
 using namespace decaf::internal;
@@ -43,8 +42,8 @@
 
         // The Platform Mutex object and an associated Condition Object
         // for use in the wait / notify pattern.
-        std::auto_ptr<MutexHandle> mutex;
-        std::auto_ptr<ConditionHandle> condition;
+        MutexHandle* mutex;
+        ConditionHandle* condition;
 
     };
 
@@ -53,34 +52,39 @@
 ////////////////////////////////////////////////////////////////////////////////
 Mutex::Mutex() {
 
-    this->properties.reset( new MutexProperties );
+    this->properties = new MutexProperties();
 
     // Allocate the OS Mutex Implementation.
-    this->properties->mutex.reset( MutexImpl::create() );
-    this->properties->condition.reset( ConditionImpl::create( this->properties->mutex.get() ) );
+    this->properties->mutex = MutexImpl::create();
+    this->properties->condition = ConditionImpl::create( this->properties->mutex );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 Mutex::~Mutex() {
     unlock();
+
+    ConditionImpl::destroy( this->properties->condition );
+    MutexImpl::destroy( this->properties->mutex );
+
+    delete this->properties;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void Mutex::lock() throw( decaf::lang::exceptions::RuntimeException ) {
 
-    MutexImpl::lock( this->properties->mutex.get() );
+    MutexImpl::lock( this->properties->mutex );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 bool Mutex::tryLock() throw( decaf::lang::exceptions::RuntimeException ) {
 
-    return MutexImpl::trylock( this->properties->mutex.get() );
+    return MutexImpl::trylock( this->properties->mutex );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void Mutex::unlock() throw( decaf::lang::exceptions::RuntimeException ) {
 
-    MutexImpl::unlock( this->properties->mutex.get() );
+    MutexImpl::unlock( this->properties->mutex );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -88,7 +92,7 @@
                           decaf::lang::exceptions::IllegalMonitorStateException,
                           decaf::lang::exceptions::InterruptedException ) {
 
-    ConditionImpl::wait( this->properties->condition.get() );
+    ConditionImpl::wait( this->properties->condition );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -117,19 +121,19 @@
             __FILE__, __LINE__, "Nanoseconds value must be in the range [0..999999]." );
     }
 
-    ConditionImpl::wait( this->properties->condition.get(), millisecs, nanos );
+    ConditionImpl::wait( this->properties->condition, millisecs, nanos );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void Mutex::notify() throw( decaf::lang::exceptions::RuntimeException,
                             decaf::lang::exceptions::IllegalMonitorStateException ) {
 
-    ConditionImpl::notify( this->properties->condition.get() );
+    ConditionImpl::notify( this->properties->condition );
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 void Mutex::notifyAll() throw( decaf::lang::exceptions::RuntimeException,
                                decaf::lang::exceptions::IllegalMonitorStateException ) {
 
-    ConditionImpl::notifyAll( this->properties->condition.get() );
+    ConditionImpl::notifyAll( this->properties->condition );
 }

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h?rev=881564&r1=881563&r2=881564&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/util/concurrent/Mutex.h Tue Nov 17 22:06:02 2009
@@ -20,7 +20,6 @@
 
 #include <decaf/util/concurrent/Synchronizable.h>
 #include <decaf/util/concurrent/Concurrent.h>
-#include <decaf/lang/Pointer.h>
 #include <decaf/lang/Thread.h>
 #include <decaf/util/Config.h>
 
@@ -40,7 +39,7 @@
     class DECAF_API Mutex : public Synchronizable {
     private:
 
-        decaf::lang::Pointer<MutexProperties> properties;
+        MutexProperties* properties;
 
     private: