diff options
author | Michi Henning <michi@zeroc.com> | 2006-02-21 04:08:40 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2006-02-21 04:08:40 +0000 |
commit | 17637b2c90916a65a844ab39a0efe7aadc590fdc (patch) | |
tree | ef5474109fd55f1778f395abc120fa3260148405 /cppe/src | |
parent | Bug 867. (diff) | |
download | ice-17637b2c90916a65a844ab39a0efe7aadc590fdc.tar.bz2 ice-17637b2c90916a65a844ab39a0efe7aadc590fdc.tar.xz ice-17637b2c90916a65a844ab39a0efe7aadc590fdc.zip |
Bug 857.
Diffstat (limited to 'cppe/src')
-rw-r--r-- | cppe/src/IceE/Reference.cpp | 24 | ||||
-rw-r--r-- | cppe/src/IceE/Reference.h | 24 |
2 files changed, 37 insertions, 11 deletions
diff --git a/cppe/src/IceE/Reference.cpp b/cppe/src/IceE/Reference.cpp index 26aaa044409..234ec78dd71 100644 --- a/cppe/src/IceE/Reference.cpp +++ b/cppe/src/IceE/Reference.cpp @@ -106,7 +106,7 @@ IceInternal::Reference::changeFacet(const string& newFacet) const Int Reference::hash() const { - IceUtil::Mutex::Lock sync(_hashMutex); + IceUtil::RecMutex::Lock sync(_hashMutex); if(_hashInitialized) { @@ -590,6 +590,11 @@ IceInternal::RoutableReference::changeRouter(const RouterPrx& newRouter) const return r; } +int +IceInternal::RoutableReference::hash() const +{ + return Reference::hash(); +} bool IceInternal::RoutableReference::operator==(const Reference& r) const @@ -1050,6 +1055,23 @@ IceInternal::IndirectReference::getConnection() 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/cppe/src/IceE/Reference.h b/cppe/src/IceE/Reference.h index 9380a25836a..11854d17fb8 100644 --- a/cppe/src/IceE/Reference.h +++ b/cppe/src/IceE/Reference.h @@ -24,7 +24,7 @@ #endif #include <IceE/ConnectionF.h> #include <IceE/Shared.h> -#include <IceE/Mutex.h> +#include <IceE/RecMutex.h> #include <IceE/Identity.h> namespace IceInternal @@ -106,6 +106,10 @@ protected: const std::string&, Mode, bool); Reference(const Reference&); + IceUtil::RecMutex _hashMutex; // For lazy initialization of hash value. + mutable Ice::Int _hashValue; + mutable bool _hashInitialized; + private: const InstancePtr _instance; @@ -116,10 +120,6 @@ private: Ice::Identity _identity; Ice::Context _context; std::string _facet; - - IceUtil::Mutex _hashMutex; // For lazy initialization of hash value. - mutable Ice::Int _hashValue; - mutable bool _hashInitialized; }; class FixedReference : public Reference @@ -173,6 +173,8 @@ public: virtual Ice::ConnectionPtr getConnection() const = 0; + int hash() const; // Conceptually const. + virtual bool operator==(const Reference&) const = 0; virtual bool operator!=(const Reference&) const = 0; virtual bool operator<(const Reference&) const = 0; @@ -272,6 +274,8 @@ public: virtual std::string toString() const; virtual Ice::ConnectionPtr getConnection() const; + int hash() const; // Conceptually const. + virtual bool operator==(const Reference&) const; virtual bool operator!=(const Reference&) const; virtual bool operator<(const Reference&) const; @@ -286,11 +290,11 @@ private: std::string _adapterId; LocatorInfoPtr _locatorInfo; -#ifdef ICEE_HAS_ROUTER
- typedef RoutableReference Parent;
-#else
- typedef Reference Parent;
-#endif
+#ifdef ICEE_HAS_ROUTER + typedef RoutableReference Parent; +#else + typedef Reference Parent; +#endif }; #endif // ICEE_HAS_LOCATOR |