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/07/31 17:46:39 UTC

svn commit: r799641 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h

Author: tabish
Date: Fri Jul 31 15:46:39 2009
New Revision: 799641

URL: http://svn.apache.org/viewvc?rev=799641&view=rev
Log:
Fixes for issues found while testing on Windows.

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h?rev=799641&r1=799640&r2=799641&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Pointer.h Fri Jul 31 15:46:39 2009
@@ -46,6 +46,8 @@
             this->counter->incrementAndGet();
         }
 
+    protected:
+
         /**
          * Swaps this instance's reference counter with the one given, this allows
          * for copy-and-swap semantics of this object.
@@ -171,7 +173,7 @@
         }
 
         virtual ~Pointer() throw() {
-            if( this->release() == true ) {
+            if( REFCOUNTER::release() == true ) {
                 delete this->value;
             }
         }
@@ -189,6 +191,23 @@
         }
 
         /**
+         * Releases the Pointer held and resets the internal pointer value to Null.  This method
+         * is not guaranteed to be safe if the Pointer is held by more than one object or this
+         * method is called from more than one thread.
+         *
+         * @param value - The new value to contain.
+         *
+         * @returns The pointer instance that was held by this Pointer object, the pointer is
+         *          no longer owned by this Pointer and won't be freed when this Pointer goes
+         *          out of scope.
+         */
+        T* release() {
+            T* temp = this->value;
+            this->value = NULL;
+            return temp;
+        }
+
+        /**
          * Gets the real pointer that is contained within this Pointer.  This is
          * not really safe since the caller could delete or alter the pointer but
          * it mimics the STL auto_ptr and gives access in cases where the caller