diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Ice/OutgoingAsync.h | 2 | ||||
-rw-r--r-- | cpp/include/Ice/Proxy.h | 32 | ||||
-rw-r--r-- | cpp/src/Ice/OutgoingAsync.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 8 | ||||
-rw-r--r-- | cpp/test/Ice/binding/AllTests.cpp | 1 |
5 files changed, 21 insertions, 28 deletions
diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index b5bd6830117..8391c6c189d 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -334,6 +334,8 @@ public: virtual AsyncStatus invokeRemote(const Ice::ConnectionIPtr&, bool, bool); virtual AsyncStatus invokeCollocated(CollocatedRequestHandler*); + virtual Ice::ConnectionPtr getConnection() const; + void invoke(const std::string&); }; typedef IceUtil::Handle<ProxyGetConnection> ProxyGetConnectionPtr; diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index 73b5cabff80..30315e7f33b 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -172,13 +172,12 @@ class ProxyGetConnectionLambda : public ProxyGetConnection, public LambdaInvoke public: ProxyGetConnectionLambda(const ::std::shared_ptr<::Ice::ObjectPrx>& proxy, - ::std::function<::std::shared_ptr<Ice::Connection>()> getConnection, ::std::function<void(::std::shared_ptr<Ice::Connection>)> response, ::std::function<void(::std::exception_ptr)> ex, ::std::function<void(bool)> sent) : ProxyGetConnection(proxy), LambdaInvoke(::std::move(ex), ::std::move(sent)) { - _response = [response, getConnection](bool) + _response = [&, response](bool) { response(getConnection()); }; @@ -190,11 +189,9 @@ class ProxyGetConnectionPromise : public ProxyGetConnection, public PromiseInvok { public: - ProxyGetConnectionPromise(const ::std::shared_ptr<::Ice::ObjectPrx>& proxy, - ::std::function<::std::shared_ptr<Ice::Connection>()> getConnection) : - ProxyGetConnection(proxy) + ProxyGetConnectionPromise(const ::std::shared_ptr<::Ice::ObjectPrx>& proxy) : ProxyGetConnection(proxy) { - this->_response = [&, getConnection](bool) + this->_response = [&](bool) { this->_promise.set_value(getConnection()); }; @@ -543,12 +540,7 @@ public: ::std::function<void(bool)> sent = nullptr) { using LambdaOutgoing = ::IceInternal::ProxyGetConnectionLambda; - auto outAsync = ::std::make_shared<LambdaOutgoing>(shared_from_this(), - [this]() - { - return ice_getCachedConnection(); - }, - response, ex, sent); + auto outAsync = ::std::make_shared<LambdaOutgoing>(shared_from_this(), response, ex, sent); __ice_getConnection(outAsync); return [outAsync]() { outAsync->cancel(); }; } @@ -557,11 +549,7 @@ public: ice_getConnectionAsync() -> decltype(std::declval<P<::std::shared_ptr<::Ice::Connection>>>().get_future()) { using PromiseOutgoing = ::IceInternal::ProxyGetConnectionPromise<P<::std::shared_ptr<::Ice::Connection>>>; - auto outAsync = ::std::make_shared<PromiseOutgoing>(shared_from_this(), - [this]() - { - return ice_getCachedConnection(); - }); + auto outAsync = ::std::make_shared<PromiseOutgoing>(shared_from_this()); __ice_getConnection(outAsync); return outAsync->getFuture(); } @@ -1326,7 +1314,7 @@ public: ::Ice::ConnectionPtr ice_getConnection() { - return end_ice_getConnection(__begin_ice_getConnection(::IceInternal::__dummyCallback, 0, true)); + return end_ice_getConnection(begin_ice_getConnection()); } ::Ice::AsyncResultPtr begin_ice_getConnection() @@ -1352,7 +1340,7 @@ public: void ice_flushBatchRequests() { - return end_ice_flushBatchRequests(__begin_ice_flushBatchRequests(::IceInternal::__dummyCallback, 0, true)); + return end_ice_flushBatchRequests(begin_ice_flushBatchRequests()); } ::Ice::AsyncResultPtr begin_ice_flushBatchRequests() @@ -1438,12 +1426,10 @@ private: bool = false); ::Ice::AsyncResultPtr __begin_ice_getConnection(const ::IceInternal::CallbackBasePtr&, - const ::Ice::LocalObjectPtr&, - bool = false); + const ::Ice::LocalObjectPtr&); ::Ice::AsyncResultPtr __begin_ice_flushBatchRequests(const ::IceInternal::CallbackBasePtr&, - const ::Ice::LocalObjectPtr&, - bool = false); + const ::Ice::LocalObjectPtr&); void setup(const ::IceInternal::ReferencePtr&); friend class ::IceInternal::ProxyFactory; diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index 20ba0b38b3a..d7ffc2f4d6d 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -1225,6 +1225,12 @@ ProxyGetConnection::invokeCollocated(CollocatedRequestHandler*) return AsyncStatusSent; } +Ice::ConnectionPtr +ProxyGetConnection::getConnection() const +{ + return _cachedConnection; +} + void ProxyGetConnection::invoke(const string& operation) { diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 119a0eb178a..a31d4022abb 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -444,8 +444,7 @@ IceProxy::Ice::Object::___end_ice_invoke(pair<const Byte*, const Byte*>& outEnca ::Ice::AsyncResultPtr IceProxy::Ice::Object::__begin_ice_flushBatchRequests(const ::IceInternal::CallbackBasePtr& del, - const ::Ice::LocalObjectPtr& cookie, - bool sync) + const ::Ice::LocalObjectPtr& cookie) { class ProxyFlushBatchAsyncWithCallback : public ProxyFlushBatchAsync, public CallbackCompletion { @@ -531,8 +530,7 @@ IceProxy::Ice::Object::__newInstance() const AsyncResultPtr IceProxy::Ice::Object::__begin_ice_getConnection(const ::IceInternal::CallbackBasePtr& del, - const ::Ice::LocalObjectPtr& cookie, - bool sync) + const ::Ice::LocalObjectPtr& cookie) { class ProxyGetConnectionWithCallback : public ProxyGetConnection, public CallbackCompletion { @@ -570,7 +568,7 @@ IceProxy::Ice::Object::end_ice_getConnection(const AsyncResultPtr& __result) { AsyncResult::__check(__result, this, ice_getConnection_name); __result->__wait(); - return ice_getCachedConnection(); + return __result->getConnection(); } void diff --git a/cpp/test/Ice/binding/AllTests.cpp b/cpp/test/Ice/binding/AllTests.cpp index 7b840621ab2..8754af1bd28 100644 --- a/cpp/test/Ice/binding/AllTests.cpp +++ b/cpp/test/Ice/binding/AllTests.cpp @@ -556,6 +556,7 @@ allTests(const Ice::CommunicatorPtr& communicator) TestIntfPrxPtr test2 = ICE_UNCHECKED_CAST(TestIntfPrx, adapter->getTestIntf()->ice_connectionCached(false)); test(!test1->ice_isConnectionCached()); test(!test2->ice_isConnectionCached()); + test(test1->ice_getConnection() && test2->ice_getConnection()); test(test1->ice_getConnection() == test2->ice_getConnection()); test1->ice_ping(); |