activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1446293 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover: URIPool.cpp URIPool.h
Date Thu, 14 Feb 2013 18:33:24 GMT
Author: tabish
Date: Thu Feb 14 18:33:23 2013
New Revision: 1446293

URL: http://svn.apache.org/r1446293
Log:
Enhance the API a bit

Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp
    activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.h

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp?rev=1446293&r1=1446292&r2=1446293&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.cpp
Thu Feb 14 18:33:23 2013
@@ -66,20 +66,24 @@ URI URIPool::getURI() {
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void URIPool::addURI(const URI& uri) {
+bool URIPool::addURI(const URI& uri) {
 
     synchronized(&uriPool) {
         if (!uriPool.contains(uri)) {
             uriPool.add(uri);
+            return true;
         }
     }
+
+    return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void URIPool::addURIs(const LinkedList<URI>& uris) {
+bool URIPool::addURIs(const LinkedList<URI>& uris) {
 
-    synchronized(&uriPool) {
+    bool result = false;
 
+    synchronized(&uriPool) {
         std::auto_ptr<Iterator<URI> > iter(uris.iterator());
 
         while (iter->hasNext()) {
@@ -87,19 +91,25 @@ void URIPool::addURIs(const LinkedList<U
 
             if (!uriPool.contains(uri)) {
                 uriPool.add(uri);
+                result = true;
             }
         }
     }
+
+    return result;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-void URIPool::removeURI(const URI& uri) {
+bool URIPool::removeURI(const URI& uri) {
 
     synchronized(&uriPool) {
         if (uriPool.contains(uri)) {
             uriPool.remove(uri);
+            return true;
         }
     }
+
+    return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.h?rev=1446293&r1=1446292&r2=1446293&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.h
(original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/failover/URIPool.h
Thu Feb 14 18:33:23 2013
@@ -71,22 +71,30 @@ namespace failover {
          * the resource that was connected to that URI.
          *
          * @param uri - a URI previously taken from the pool.
+         *
+         * @returns true if the URI was added or false if its already in the list.
          */
-        void addURI(const URI& uri);
+        bool addURI(const URI& uri);
 
         /**
          * Adds a List of URIs to this Pool, the method checks for duplicates already
          * in the pool and does not add those.
          *
          * @param uris - List of URIs to add into the Pool.
+         *
+         * @returns true if any URI was added or false if they were already in the list.
          */
-        void addURIs(const LinkedList<URI>& uris);
+        bool addURIs(const LinkedList<URI>& uris);
 
         /**
          * Remove a given URI from the Free List.
-         * @param uri - the URI to find and remove from the free list
+         *
+         * @param uri
+         *      The URI to find and remove from the free list
+         *
+         * @returns true if the URI was removed or false if no change was made.
          */
-        void removeURI(const URI& uri);
+        bool removeURI(const URI& uri);
 
         /**
          * Is the URI that is given randomly picked from the pool or is



Mime
View raw message