summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2006-02-21 04:08:40 +0000
committerMichi Henning <michi@zeroc.com>2006-02-21 04:08:40 +0000
commit17637b2c90916a65a844ab39a0efe7aadc590fdc (patch)
treeef5474109fd55f1778f395abc120fa3260148405 /cpp
parentBug 867. (diff)
downloadice-17637b2c90916a65a844ab39a0efe7aadc590fdc.tar.bz2
ice-17637b2c90916a65a844ab39a0efe7aadc590fdc.tar.xz
ice-17637b2c90916a65a844ab39a0efe7aadc590fdc.zip
Bug 857.
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/Reference.cpp25
-rw-r--r--cpp/src/Ice/Reference.h16
2 files changed, 34 insertions, 7 deletions
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index 6ebe481ea3f..0a84aced76c 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -118,7 +118,7 @@ IceInternal::Reference::changeEndpointSelection(EndpointSelectionType newType) c
Int
Reference::hash() const
{
- IceUtil::Mutex::Lock sync(_hashMutex);
+ IceUtil::RecMutex::Lock sync(_hashMutex);
if(_hashInitialized)
{
@@ -759,6 +759,12 @@ IceInternal::RoutableReference::changeCollocationOptimization(bool newCollocatio
return r;
}
+int
+IceInternal::RoutableReference::hash() const
+{
+ return Reference::hash();
+}
+
bool
IceInternal::RoutableReference::operator==(const Reference& r) const
{
@@ -1469,6 +1475,23 @@ IceInternal::IndirectReference::getConnection(bool& comp) const
return connection;
}
+int
+IceInternal::IndirectReference::hash() const
+{
+ IceUtil::RecMutex::Lock sync(_hashMutex);
+
+ if(_hashInitialized)
+ {
+ return _hashValue;
+ }
+ RoutableReference::hash(); // Initializes _hashValue.
+ for(string::const_iterator p = _adapterId.begin(); p != _adapterId.end(); ++p) // Add hash of adapter ID to base hash.
+ {
+ _hashValue = 5 * _hashValue + *p;
+ }
+ return _hashValue;
+}
+
bool
IceInternal::IndirectReference::operator==(const Reference& r) const
{
diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h
index 7d7d55a2856..7f67f2aa41c 100644
--- a/cpp/src/Ice/Reference.h
+++ b/cpp/src/Ice/Reference.h
@@ -11,7 +11,7 @@
#define ICE_REFERENCE_H
#include <IceUtil/Shared.h>
-#include <IceUtil/Mutex.h>
+#include <IceUtil/RecMutex.h>
#include <Ice/ReferenceF.h>
#include <Ice/ReferenceFactoryF.h>
#include <Ice/EndpointIF.h>
@@ -83,7 +83,7 @@ public:
virtual ReferencePtr changeEndpoints(const std::vector<EndpointIPtr>&) const = 0;
virtual ReferencePtr changeLocatorCacheTimeout(int) const = 0;
- int hash() const; // Conceptually const.
+ virtual int hash() const; // Conceptually const.
//
// Marshal the reference.
@@ -112,6 +112,10 @@ protected:
const std::string&, Mode);
Reference(const Reference&);
+ IceUtil::RecMutex _hashMutex; // For lazy initialization of hash value.
+ mutable Ice::Int _hashValue;
+ mutable bool _hashInitialized;
+
private:
const InstancePtr _instance;
@@ -123,10 +127,6 @@ private:
std::string _facet;
bool _cacheConnection;
Ice::EndpointSelectionType _endpointSelection;
-
- IceUtil::Mutex _hashMutex; // For lazy initialization of hash value.
- mutable Ice::Int _hashValue;
- mutable bool _hashInitialized;
};
class FixedReference : public Reference
@@ -193,6 +193,8 @@ public:
virtual Ice::ConnectionIPtr getConnection(bool&) const = 0;
+ virtual int hash() const;
+
virtual bool operator==(const Reference&) const = 0;
virtual bool operator!=(const Reference&) const = 0;
virtual bool operator<(const Reference&) const = 0;
@@ -278,6 +280,8 @@ public:
virtual std::string toString() const;
virtual Ice::ConnectionIPtr getConnection(bool&) const;
+ virtual int hash() const; // Conceptually const.
+
virtual bool operator==(const Reference&) const;
virtual bool operator!=(const Reference&) const;
virtual bool operator<(const Reference&) const;