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 2013/12/11 20:19:37 UTC

git commit: https://issues.apache.org/jira/browse/AMQCPP-527

Updated Branches:
  refs/heads/3.8.x 42c52c152 -> ea015f3a2


https://issues.apache.org/jira/browse/AMQCPP-527

Workaround MS's bad stl implementation.

Project: http://git-wip-us.apache.org/repos/asf/activemq-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-cpp/commit/ea015f3a
Tree: http://git-wip-us.apache.org/repos/asf/activemq-cpp/tree/ea015f3a
Diff: http://git-wip-us.apache.org/repos/asf/activemq-cpp/diff/ea015f3a

Branch: refs/heads/3.8.x
Commit: ea015f3a29aaa653576184506f49b8e118a42da1
Parents: 42c52c1
Author: Timothy Bish <ta...@gmai.com>
Authored: Wed Dec 11 14:19:27 2013 -0500
Committer: Timothy Bish <ta...@gmai.com>
Committed: Wed Dec 11 14:19:27 2013 -0500

----------------------------------------------------------------------
 .../decaf/util/concurrent/ConcurrentStlMap.h    | 39 +++++++++++++-------
 1 file changed, 25 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-cpp/blob/ea015f3a/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h
----------------------------------------------------------------------
diff --git a/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h b/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h
index 087c069..f90f3e9 100644
--- a/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h
+++ b/activemq-cpp/src/main/decaf/util/concurrent/ConcurrentStlMap.h
@@ -774,8 +774,11 @@ namespace concurrent{
             typename std::map<K, V, COMPARATOR>::const_iterator iter;
 
             synchronized(&mutex) {
-                iter = valueMap.find(key);
-                return iter != valueMap.end();
+
+                if (!valueMap.empty()) {
+                    iter = valueMap.find(key);
+                    return iter != valueMap.end();
+                }
             }
 
             return false;
@@ -829,9 +832,12 @@ namespace concurrent{
         virtual V& get(const K& key) {
             typename std::map<K,V,COMPARATOR>::iterator iter;
             synchronized(&mutex) {
-                iter = valueMap.find(key);
-                if (iter != valueMap.end()) {
-                    return iter->second;
+
+                if (!valueMap.empty()) {
+                    iter = valueMap.find(key);
+                    if (iter != valueMap.end()) {
+                        return iter->second;
+                    }
                 }
             }
 
@@ -845,9 +851,11 @@ namespace concurrent{
         virtual const V& get(const K& key) const {
             typename std::map<K,V,COMPARATOR>::const_iterator iter;
             synchronized(&mutex) {
-                iter = valueMap.find(key);
-                if (iter != valueMap.end()) {
-                    return iter->second;
+                if (!valueMap.empty()) {
+                    iter = valueMap.find(key);
+                    if (iter != valueMap.end()) {
+                        return iter->second;
+                    }
                 }
             }
 
@@ -916,13 +924,16 @@ namespace concurrent{
         virtual V remove(const K& key) {
             V result = V();
             synchronized(&mutex) {
-                typename std::map<K, V, COMPARATOR>::iterator iter = valueMap.find(key);
-                if (iter == valueMap.end()) {
-                    return result;
+
+                if (!valueMap.empty()) {
+                    typename std::map<K, V, COMPARATOR>::iterator iter = valueMap.find(key);
+                    if (iter == valueMap.end()) {
+                        return result;
+                    }
+                    result = iter->second;
+                    valueMap.erase(iter);
+                    modCount++;
                 }
-                result = iter->second;
-                valueMap.erase(iter);
-                modCount++;
             }
 
             return result;