diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 32 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 65 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.h | 5 | ||||
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.cpp | 9 | ||||
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.h | 3 |
6 files changed, 91 insertions, 29 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 2165d01d46b..4a78165d898 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -476,7 +476,7 @@ Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) // vector<EndpointPtr> endpoints; ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, - false, false, "", endpoints, 0, 0, this); + false, false, "", endpoints, 0, 0, this, true); return _instance->proxyFactory()->referenceToProxy(ref); } @@ -720,7 +720,7 @@ Ice::ObjectAdapterI::newProxy(const Identity& ident) const // vector<EndpointPtr> endpoints; ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, - false, false, _id, endpoints, 0, 0, 0); + false, false, _id, endpoints, 0, 0, 0, true); // // Return a proxy for the reference. @@ -755,7 +755,7 @@ Ice::ObjectAdapterI::newDirectProxy(const Identity& ident) const // Create a reference and return a proxy for this reference. // ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, - false, false, "", endpoints, 0, 0, 0); + false, false, "", endpoints, 0, 0, 0, true); return _instance->proxyFactory()->referenceToProxy(ref); } diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index a39b3eafe89..2176d2874a0 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -501,6 +501,22 @@ IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const } ObjectPrx +IceProxy::Ice::Object::ice_collocationOptimization(bool b) const +{ + ReferencePtr ref = _reference->changeCollocationOptimization(b); + if(ref == _reference) + { + return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); + } + else + { + ObjectPrx proxy(new ::IceProxy::Ice::Object()); + proxy->setup(ref); + return proxy; + } +} + +ObjectPrx IceProxy::Ice::Object::ice_default() const { ReferencePtr ref = _reference->changeDefault(); @@ -664,14 +680,18 @@ IceProxy::Ice::Object::__getDelegate() throw CommunicatorDestroyedException(__FILE__, __LINE__); } - ObjectAdapterPtr adapter = objectAdapterFactory->findObjectAdapter(this); - if(adapter) + if(_reference->collocationOptimization) { - Handle< ::IceDelegateD::Ice::Object> delegate = __createDelegateD(); - delegate->setup(_reference, adapter); - _delegate = delegate; + ObjectAdapterPtr adapter = objectAdapterFactory->findObjectAdapter(this); + if(adapter) + { + Handle< ::IceDelegateD::Ice::Object> delegate = __createDelegateD(); + delegate->setup(_reference, adapter); + _delegate = delegate; + } } - else + + if(!_delegate) { Handle< ::IceDelegateM::Ice::Object> delegate = __createDelegateM(); delegate->setup(_reference); diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index 53543719ae4..18f3443bb0d 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -90,6 +90,11 @@ IceInternal::Reference::operator==(const Reference& r) const return false; } + if(collocationOptimization != r.collocationOptimization) + { + return false; + } + return true; } @@ -197,6 +202,15 @@ IceInternal::Reference::operator<(const Reference& r) const return false; } + if(!collocationOptimization && r.collocationOptimization) + { + return true; + } + else if(r.collocationOptimization < collocationOptimization) + { + return false; + } + return false; } @@ -371,7 +385,8 @@ IceInternal::Reference::changeIdentity(const Identity& newIdentity) const else { return instance->referenceFactory()->create(newIdentity, facet, mode, secure, compress, adapterId, - endpoints, routerInfo, locatorInfo, reverseAdapter); + endpoints, routerInfo, locatorInfo, reverseAdapter, + collocationOptimization); } } @@ -385,7 +400,8 @@ IceInternal::Reference::changeFacet(const FacetPath& newFacet) const else { return instance->referenceFactory()->create(identity, newFacet, mode, secure, compress, adapterId, - endpoints, routerInfo, locatorInfo, reverseAdapter); + endpoints, routerInfo, locatorInfo, reverseAdapter, + collocationOptimization); } } @@ -435,7 +451,8 @@ IceInternal::Reference::changeTimeout(int timeout) const } return instance->referenceFactory()->create(identity, facet, mode, secure, compress, adapterId, - newEndpoints, newRouterInfo, newLocatorInfo, reverseAdapter); + newEndpoints, newRouterInfo, newLocatorInfo, reverseAdapter, + collocationOptimization); } ReferencePtr @@ -448,7 +465,8 @@ IceInternal::Reference::changeMode(Mode newMode) const else { return instance->referenceFactory()->create(identity, facet, newMode, secure, compress, adapterId, - endpoints, routerInfo, locatorInfo, reverseAdapter); + endpoints, routerInfo, locatorInfo, reverseAdapter, + collocationOptimization); } } @@ -462,7 +480,8 @@ IceInternal::Reference::changeSecure(bool newSecure) const else { return instance->referenceFactory()->create(identity, facet, mode, newSecure, compress, adapterId, - endpoints, routerInfo, locatorInfo, reverseAdapter); + endpoints, routerInfo, locatorInfo, reverseAdapter, + collocationOptimization); } } @@ -476,7 +495,8 @@ IceInternal::Reference::changeCompress(bool newCompress) const else { return instance->referenceFactory()->create(identity, facet, mode, secure, newCompress, adapterId, - endpoints, routerInfo, locatorInfo, reverseAdapter); + endpoints, routerInfo, locatorInfo, reverseAdapter, + collocationOptimization); } } @@ -490,7 +510,8 @@ IceInternal::Reference::changeAdapterId(const string& newAdapterId) const else { return instance->referenceFactory()->create(identity, facet, mode, secure, compress, newAdapterId, - endpoints, routerInfo, locatorInfo, reverseAdapter); + endpoints, routerInfo, locatorInfo, reverseAdapter, + collocationOptimization); } } @@ -504,7 +525,8 @@ IceInternal::Reference::changeEndpoints(const vector<EndpointPtr>& newEndpoints) else { return instance->referenceFactory()->create(identity, facet, mode, secure, compress, adapterId, - newEndpoints, routerInfo, locatorInfo, reverseAdapter); + newEndpoints, routerInfo, locatorInfo, reverseAdapter, + collocationOptimization); } } @@ -520,7 +542,8 @@ IceInternal::Reference::changeRouter(const RouterPrx& newRouter) const else { return instance->referenceFactory()->create(identity, facet, mode, secure, compress, adapterId, - endpoints, newRouterInfo, locatorInfo, reverseAdapter); + endpoints, newRouterInfo, locatorInfo, reverseAdapter, + collocationOptimization); } } @@ -536,7 +559,23 @@ IceInternal::Reference::changeLocator(const LocatorPrx& newLocator) const else { return instance->referenceFactory()->create(identity, facet, mode, secure, compress, adapterId, - endpoints, routerInfo, newLocatorInfo, reverseAdapter); + endpoints, routerInfo, newLocatorInfo, reverseAdapter, + collocationOptimization); + } +} + +ReferencePtr +IceInternal::Reference::changeCollocationOptimization(bool newCollocationOptimization) const +{ + if(newCollocationOptimization == collocationOptimization) + { + return ReferencePtr(const_cast<Reference*>(this)); + } + else + { + return instance->referenceFactory()->create(identity, facet, mode, secure, compress, adapterId, + endpoints, routerInfo, locatorInfo, reverseAdapter, + newCollocationOptimization); } } @@ -547,7 +586,7 @@ IceInternal::Reference::changeDefault() const LocatorInfoPtr locatorInfo = instance->locatorManager()->get(instance->referenceFactory()->getDefaultLocator()); return instance->referenceFactory()->create(identity, FacetPath(), ModeTwoway, false, false, adapterId, - endpoints, routerInfo, locatorInfo, 0); + endpoints, routerInfo, locatorInfo, 0, true); } IceInternal::Reference::Reference(const InstancePtr& inst, @@ -560,7 +599,8 @@ IceInternal::Reference::Reference(const InstancePtr& inst, const vector<EndpointPtr>& endpts, const RouterInfoPtr& rtrInfo, const LocatorInfoPtr& locInfo, - const ObjectAdapterPtr& rvAdapter) : + const ObjectAdapterPtr& rvAdapter, + bool collocationOptimization) : instance(inst), identity(ident), facet(facPath), @@ -572,6 +612,7 @@ IceInternal::Reference::Reference(const InstancePtr& inst, routerInfo(rtrInfo), locatorInfo(locInfo), reverseAdapter(rvAdapter), + collocationOptimization(collocationOptimization), hashValue(0) { // diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index a79ed7b5dd5..64148113414 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -74,6 +74,7 @@ public: const RouterInfoPtr routerInfo; // Null if no router is used. const LocatorInfoPtr locatorInfo; // Null if no locator is used. const Ice::ObjectAdapterPtr reverseAdapter; // For reverse communications using the adapter's incoming connections. + const bool collocationOptimization; const Ice::Int hashValue; // @@ -90,14 +91,14 @@ public: ReferencePtr changeEndpoints(const std::vector<EndpointPtr>&) const; ReferencePtr changeRouter(const ::Ice::RouterPrx&) const; ReferencePtr changeLocator(const ::Ice::LocatorPrx&) const; + ReferencePtr changeCollocationOptimization(bool) const; ReferencePtr changeDefault() const; private: Reference(const InstancePtr&, const Ice::Identity&, const Ice::FacetPath&, Mode, bool, bool, const std::string&, const std::vector<EndpointPtr>&, - const RouterInfoPtr&, const LocatorInfoPtr&, - const Ice::ObjectAdapterPtr&); + const RouterInfoPtr&, const LocatorInfoPtr&, const Ice::ObjectAdapterPtr&, bool); friend class ReferenceFactory; }; diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index 991a9cb660c..c9a467d5004 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -40,7 +40,8 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const vector<EndpointPtr>& endpoints, const RouterInfoPtr& routerInfo, const LocatorInfoPtr& locatorInfo, - const ObjectAdapterPtr& reverseAdapter) + const ObjectAdapterPtr& reverseAdapter, + bool collocationOptimization) { Mutex::Lock sync(*this); @@ -58,7 +59,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // Create new reference // ReferencePtr ref = new Reference(_instance, ident, facet, mode, secure, compress, adapterId, - endpoints, routerInfo, locatorInfo, reverseAdapter); + endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); // // If we already have an equivalent reference, use such equivalent @@ -505,7 +506,7 @@ IceInternal::ReferenceFactory::create(const string& str) RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter()); LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); - return create(ident, facet, mode, secure, compress, adapter, endpoints, routerInfo, locatorInfo, 0); + return create(ident, facet, mode, secure, compress, adapter, endpoints, routerInfo, locatorInfo, 0, true); } ReferencePtr @@ -560,7 +561,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter()); LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); - return create(ident, facet, mode, secure, compress, adapterId, endpoints, routerInfo, locatorInfo, 0); + return create(ident, facet, mode, secure, compress, adapterId, endpoints, routerInfo, locatorInfo, 0, true); } void diff --git a/cpp/src/Ice/ReferenceFactory.h b/cpp/src/Ice/ReferenceFactory.h index e30fed89bdf..296e4ba735f 100644 --- a/cpp/src/Ice/ReferenceFactory.h +++ b/cpp/src/Ice/ReferenceFactory.h @@ -30,8 +30,7 @@ public: ReferencePtr create(const Ice::Identity&, const std::vector<std::string>&, Reference::Mode, bool, bool, const std::string&, const std::vector<EndpointPtr>&, - const RouterInfoPtr&, const LocatorInfoPtr&, - const Ice::ObjectAdapterPtr&); + const RouterInfoPtr&, const LocatorInfoPtr&, const Ice::ObjectAdapterPtr&, bool); ReferencePtr create(const std::string&); ReferencePtr create(const Ice::Identity&, BasicStream*); |