activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r598077 - in /activemq/activemq-cpp/decaf/trunk/src: main/decaf/internal/nio/ByteArrayPerspective.cpp main/decaf/internal/nio/ByteArrayPerspective.h test/decaf/internal/nio/ByteArrayPerspectiveTest.cpp
Date Sun, 25 Nov 2007 22:57:30 GMT
Author: tabish
Date: Sun Nov 25 14:57:30 2007
New Revision: 598077

URL: http://svn.apache.org/viewvc?rev=598077&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQCPP-103

Working on the NIO package

Modified:
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayPerspective.cpp
    activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayPerspective.h
    activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ByteArrayPerspectiveTest.cpp

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayPerspective.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayPerspective.cpp?rev=598077&r1=598076&r2=598077&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayPerspective.cpp
(original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayPerspective.cpp
Sun Nov 25 14:57:30 2007
@@ -24,7 +24,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 ByteArrayPerspective::ByteArrayPerspective( int capacity ) : ByteArray( capacity ){
-    this->references = 0;
+    this->references = 1;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -32,5 +32,5 @@
     throw( lang::exceptions::NullPointerException ) :
         ByteArray( array, capacity, own ) {
 
-    this->references = 0;
+    this->references = 1;
 }

Modified: activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayPerspective.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayPerspective.h?rev=598077&r1=598076&r2=598077&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayPerspective.h (original)
+++ activemq/activemq-cpp/decaf/trunk/src/main/decaf/internal/nio/ByteArrayPerspective.h Sun
Nov 25 14:57:30 2007
@@ -28,6 +28,9 @@
      * This class extends ByteArray to create a reference counted byte array
      * that can be held and used by several differen ByteBuffers and allow them
      * to know on destruction whose job it is to delete the perspective.
+     * <p>
+     * Creating an instance of this class implicity takes a reference to it, so
+     * a creator must return its ref before the count will be zero.
      */
     class ByteArrayPerspective : public util::ByteArray {
     private:
@@ -59,9 +62,14 @@
         virtual ~ByteArrayPerspective() {}
 
         /**
-         * Takes a reference to this Perspective
+         * Takes a reference to this Perspective and returns a pointer to this
+         * so that a caller can take a ref and get a ref in one call.
+         * @returns this
          */
-        void takeRef() { this->references++; }
+        ByteArrayPerspective* takeRef() {
+            this->references++;
+            return this;
+        }
 
         /**
          * Returns a reference to this Perspective, when the count is zero

Modified: activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ByteArrayPerspectiveTest.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ByteArrayPerspectiveTest.cpp?rev=598077&r1=598076&r2=598077&view=diff
==============================================================================
--- activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ByteArrayPerspectiveTest.cpp
(original)
+++ activemq/activemq-cpp/decaf/trunk/src/test/decaf/internal/nio/ByteArrayPerspectiveTest.cpp
Sun Nov 25 14:57:30 2007
@@ -29,7 +29,6 @@
 void ByteArrayPerspectiveTest::testReferences(){
 
     ByteArrayPerspective array( (std::size_t)256 );
-    array.takeRef();
     CPPUNIT_ASSERT( array.getReferences() == 1 );
     array.takeRef();
     CPPUNIT_ASSERT( array.getReferences() == 2 );



Mime
View raw message