From 383f3da08e58a9a3d44193af36e15cddcb4733a8 Mon Sep 17 00:00:00 2001 From: Joe George Date: Thu, 22 Feb 2024 19:43:14 -0500 Subject: [PATCH 1/2] Revert "Add MATLAB ci for Ubuntu" This reverts commit 5729bbc265a435f35d4fbc9fe934a393c17a898f. --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2c81d401ad..79e3eea41d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,8 +50,6 @@ jobs: language: python - os: ubuntu-latest language: js - - os: ubuntu-latest - language: matlab - os: windows-latest language: python From bd60710acd5d786953ebf89011b44c7575944aa9 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Fri, 23 Feb 2024 09:03:05 -0500 Subject: [PATCH 2/2] Outgoing cleanup (#1838) --- cpp/include/Ice/Communicator.h | 23 +------ cpp/include/Ice/Connection.h | 52 ++------------- cpp/include/Ice/Ice.h | 2 - cpp/include/Ice/OutgoingAsync.h | 83 ++++++++++++++---------- cpp/include/Ice/OutgoingAsyncF.h | 26 -------- cpp/include/Ice/Proxy.h | 20 ------ cpp/include/IceBT/ConnectionInfo.h | 1 - cpp/include/IceIAP/ConnectionInfo.h | 1 - cpp/include/IceSSL/ConnectionInfo.h | 1 - cpp/src/Ice/CollocatedRequestHandler.cpp | 2 +- cpp/src/Ice/Communicator.cpp | 23 +++++++ cpp/src/Ice/CommunicatorI.cpp | 2 +- cpp/src/Ice/CommunicatorI.h | 5 +- cpp/src/Ice/ConnectRequestHandler.cpp | 2 +- cpp/src/Ice/Connection.cpp | 42 ++++++++++++ cpp/src/Ice/ConnectionFactory.cpp | 1 - cpp/src/Ice/ConnectionFactory.h | 3 + cpp/src/Ice/ConnectionI.cpp | 1 - cpp/src/Ice/ConnectionI.h | 2 +- cpp/src/Ice/FixedRequestHandler.cpp | 2 +- cpp/src/Ice/ObjectAdapterI.h | 9 ++- cpp/src/Ice/OutgoingAsync.cpp | 12 ++-- cpp/src/Ice/ProxyAsync.cpp | 73 ++++++++++----------- cpp/src/Ice/ProxyFactory.cpp | 1 - cpp/src/Ice/RequestHandler.h | 7 +- cpp/src/Ice/RetryQueue.cpp | 2 +- cpp/src/Ice/RetryQueue.h | 7 +- cpp/src/IceBox/Service.cpp | 1 - cpp/src/IceGridLib/PluginFacade.cpp | 1 - cpp/src/IceStorm/Instrumentation.cpp | 1 - cpp/src/slice2cpp/Gen.cpp | 15 +++-- 31 files changed, 203 insertions(+), 220 deletions(-) delete mode 100644 cpp/include/Ice/OutgoingAsyncF.h diff --git a/cpp/include/Ice/Communicator.h b/cpp/include/Ice/Communicator.h index 8239d2b47c5..e0de8dc3218 100644 --- a/cpp/include/Ice/Communicator.h +++ b/cpp/include/Ice/Communicator.h @@ -317,10 +317,7 @@ class ICE_CLASS(ICE_API) Communicator * @param compress Specifies whether or not the queued batch requests should be compressed before being sent over * the wire. */ - virtual void flushBatchRequests(CompressBatch compress) - { - flushBatchRequestsAsync(compress).get(); - } + ICE_MEMBER(ICE_API) void flushBatchRequests(CompressBatch compress); /** * Flush any pending batch requests for this communicator. This means all batch requests invoked on fixed proxies @@ -345,23 +342,7 @@ class ICE_CLASS(ICE_API) Communicator * the wire. * @return The future object for the invocation. */ - template class P = ::std::promise> - auto flushBatchRequestsAsync(CompressBatch compress) - -> decltype(::std::declval>().get_future()) - { - using Promise = P; - auto promise = ::std::make_shared(); - flushBatchRequestsAsync(compress, - [promise](::std::exception_ptr ex) - { - promise->set_exception(::std::move(ex)); - }, - [promise](bool) - { - promise->set_value(); - }); - return promise->get_future(); - } + ICE_MEMBER(ICE_API) std::future flushBatchRequestsAsync(CompressBatch compress); /** * Add the Admin object with all its facets to the provided object adapter. If Ice.Admin.ServerId is diff --git a/cpp/include/Ice/Connection.h b/cpp/include/Ice/Connection.h index 3586397a3da..cb4f2fb0231 100644 --- a/cpp/include/Ice/Connection.h +++ b/cpp/include/Ice/Connection.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -304,10 +303,7 @@ class ICE_CLASS(ICE_API) Connection * @param compress Specifies whether or not the queued batch requests should be compressed before being sent over * the wire. */ - virtual void flushBatchRequests(CompressBatch compress) - { - flushBatchRequestsAsync(compress).get(); - } + ICE_MEMBER(ICE_API) void flushBatchRequests(CompressBatch compress); /** * Flush any pending batch requests for this connection. This means all batch requests invoked on fixed proxies @@ -330,23 +326,7 @@ class ICE_CLASS(ICE_API) Connection * the wire. * @return The future object for the invocation. */ - template class P = ::std::promise> - auto flushBatchRequestsAsync(CompressBatch compress) - -> decltype(::std::declval>().get_future()) - { - using Promise = P; - auto promise = ::std::make_shared(); - flushBatchRequestsAsync(compress, - [promise](::std::exception_ptr ex) - { - promise->set_exception(::std::move(ex)); - }, - [promise](bool) - { - promise->set_value(); - }); - return promise->get_future(); - } + ICE_MEMBER(ICE_API) std::future flushBatchRequestsAsync(CompressBatch compress); /** * Set a close callback on the connection. The callback is called by the connection when it's closed. The callback @@ -366,10 +346,7 @@ class ICE_CLASS(ICE_API) Connection /** * Send a heartbeat message. */ - virtual void heartbeat() - { - heartbeatAsync().get(); - } + ICE_MEMBER(ICE_API) void heartbeat(); /** * Send a heartbeat message. @@ -385,28 +362,13 @@ class ICE_CLASS(ICE_API) Connection * Send a heartbeat message. * @return The future object for the invocation. */ - template class P = ::std::promise> - auto heartbeatAsync() - -> decltype(::std::declval>().get_future()) - { - using Promise = P; - auto promise = ::std::make_shared(); - heartbeatAsync([promise](::std::exception_ptr ex) - { - promise->set_exception(::std::move(ex)); - }, - [promise](bool) - { - promise->set_value(); - }); - return promise->get_future(); - } + ICE_MEMBER(ICE_API) std::future heartbeatAsync(); /** * Set the active connection management parameters. * @param timeout The timeout value in seconds, must be >= 0. * @param close The close condition - * @param heartbeat The hertbeat condition + * @param heartbeat The heartbeat condition */ virtual void setACM(const std::optional& timeout, const std::optional& close, const std::optional& heartbeat) = 0; @@ -481,7 +443,7 @@ class ICE_CLASS(ICE_API) IPConnectionInfo : public ::Ice::ConnectionInfo /** * One-shot constructor to initialize all data members. - * @param underlying The information of the underyling transport or null if there's no underlying transport. + * @param underlying The information of the underlying transport or null if there's no underlying transport. * @param incoming Whether or not the connection is an incoming or outgoing connection. * @param adapterName The name of the adapter associated with the connection. * @param connectionId The connection id. @@ -540,7 +502,7 @@ class ICE_CLASS(ICE_API) TCPConnectionInfo : public ::Ice::IPConnectionInfo /** * One-shot constructor to initialize all data members. - * @param underlying The information of the underyling transport or null if there's no underlying transport. + * @param underlying The information of the underlying transport or null if there's no underlying transport. * @param incoming Whether or not the connection is an incoming or outgoing connection. * @param adapterName The name of the adapter associated with the connection. * @param connectionId The connection id. diff --git a/cpp/include/Ice/Ice.h b/cpp/include/Ice/Ice.h index 566490b809d..af866498d23 100644 --- a/cpp/include/Ice/Ice.h +++ b/cpp/include/Ice/Ice.h @@ -9,14 +9,12 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index 278d313e361..011537ac648 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -6,7 +6,6 @@ #define ICE_OUTGOING_ASYNC_H #include -#include #include #include #include @@ -23,6 +22,7 @@ namespace IceInternal { +class OutgoingAsyncBase; class RetryException; class CollocatedRequestHandler; @@ -136,6 +136,8 @@ class ICE_API OutgoingAsyncBase : public virtual OutgoingAsyncCompletionCallback static const unsigned char Sent; }; +using OutgoingAsyncBasePtr = ::std::shared_ptr; + // // Base class for proxy based invocations. This class handles the // retry for proxy invocations. It also ensures the child observer is @@ -164,7 +166,7 @@ class ICE_API ProxyOutgoingAsyncBase : public OutgoingAsyncBase, protected: - ProxyOutgoingAsyncBase(const Ice::ObjectPrx&); + ProxyOutgoingAsyncBase(Ice::ObjectPrx); ~ProxyOutgoingAsyncBase(); void invokeImpl(bool); @@ -184,6 +186,8 @@ class ICE_API ProxyOutgoingAsyncBase : public OutgoingAsyncBase, bool _sent; }; +using ProxyOutgoingAsyncBasePtr = ::std::shared_ptr; + // // Class for handling Slice operation invocations // @@ -191,7 +195,7 @@ class ICE_API OutgoingAsync : public ProxyOutgoingAsyncBase { public: - OutgoingAsync(const Ice::ObjectPrx&, bool); + OutgoingAsync(Ice::ObjectPrx, bool); void prepare(const std::string&, Ice::OperationMode, const Ice::Context&); @@ -220,7 +224,7 @@ class ICE_API OutgoingAsync : public ProxyOutgoingAsyncBase { _os.writeEmptyEncapsulation(_encoding); } - void writeParamEncaps(const ::Ice::Byte* encaps, ::std::int32_t size) + void writeParamEncaps(const ::Ice::Byte* encaps, std::int32_t size) { if(size == 0) { @@ -239,16 +243,13 @@ class ICE_API OutgoingAsync : public ProxyOutgoingAsyncBase bool _synchronous; }; -} - -namespace IceInternal -{ +using OutgoingAsyncPtr = ::std::shared_ptr; class ICE_API LambdaInvoke : public virtual OutgoingAsyncCompletionCallback { public: - LambdaInvoke(std::function exception, std::function sent) : + LambdaInvoke(std::function exception, std::function sent) : _exception(std::move(exception)), _sent(std::move(sent)) { } @@ -263,25 +264,21 @@ class ICE_API LambdaInvoke : public virtual OutgoingAsyncCompletionCallback virtual void handleInvokeException(std::exception_ptr, OutgoingAsyncBase*) const override; virtual void handleInvokeResponse(bool, OutgoingAsyncBase*) const override; - std::function _exception; + std::function _exception; std::function _sent; std::function _response; }; -template +template class PromiseInvoke : public virtual OutgoingAsyncCompletionCallback { public: - auto - getFuture() -> decltype(std::declval().get_future()) - { - return _promise.get_future(); - } + std::future getFuture() { return _promise.get_future(); } protected: - Promise _promise; + std::promise _promise; std::function _response; private: @@ -388,11 +385,11 @@ class LambdaOutgoing : public OutgoingAsyncT, public LambdaInvoke { public: - LambdaOutgoing(const Ice::ObjectPrx& proxy, + LambdaOutgoing(Ice::ObjectPrx proxy, std::function response, - std::function ex, + std::function ex, std::function sent) : - OutgoingAsyncT(proxy, false), LambdaInvoke(std::move(ex), std::move(sent)) + OutgoingAsyncT(std::move(proxy), false), LambdaInvoke(std::move(ex), std::move(sent)) { _response = [this, response = std::move(response)](bool ok) { @@ -424,11 +421,11 @@ class LambdaOutgoing : public OutgoingAsyncT, public LambdaInvoke { public: - LambdaOutgoing(const Ice::ObjectPrx& proxy, + LambdaOutgoing(Ice::ObjectPrx proxy, std::function response, - std::function ex, + std::function ex, std::function sent) : - OutgoingAsyncT(proxy, false), LambdaInvoke(std::move(ex), std::move(sent)) + OutgoingAsyncT(std::move(proxy), false), LambdaInvoke(std::move(ex), std::move(sent)) { _response = [this, response = std::move(response)](bool ok) { @@ -460,11 +457,11 @@ class CustomLambdaOutgoing : public OutgoingAsync, public LambdaInvoke { public: - CustomLambdaOutgoing(const Ice::ObjectPrx& proxy, + CustomLambdaOutgoing(Ice::ObjectPrx proxy, std::function read, - std::function ex, + std::function ex, std::function sent) : - OutgoingAsync(proxy, false), LambdaInvoke(std::move(ex), std::move(sent)) + OutgoingAsync(std::move(proxy), false), LambdaInvoke(std::move(ex), std::move(sent)) { _response = [this, read = std::move(read)](bool ok) { @@ -495,13 +492,13 @@ class CustomLambdaOutgoing : public OutgoingAsync, public LambdaInvoke } }; -template -class PromiseOutgoing : public OutgoingAsyncT, public PromiseInvoke

+template +class PromiseOutgoing : public OutgoingAsyncT, public PromiseInvoke { public: - PromiseOutgoing(const Ice::ObjectPrx& proxy, bool sync) : - OutgoingAsyncT(proxy, sync) + PromiseOutgoing(Ice::ObjectPrx proxy, bool sync) : + OutgoingAsyncT(std::move(proxy), sync) { this->_response = [this](bool ok) { @@ -521,13 +518,13 @@ class PromiseOutgoing : public OutgoingAsyncT, public PromiseInvoke

} }; -template -class PromiseOutgoing : public OutgoingAsyncT, public PromiseInvoke

+template<> +class PromiseOutgoing : public OutgoingAsyncT, public PromiseInvoke { public: - PromiseOutgoing(const Ice::ObjectPrx& proxy, bool sync) : - OutgoingAsyncT(proxy, sync) + PromiseOutgoing(Ice::ObjectPrx proxy, bool sync) : + OutgoingAsyncT(std::move(proxy), sync) { this->_response = [&](bool ok) { @@ -556,12 +553,28 @@ class PromiseOutgoing : public OutgoingAsyncT, public PromiseInvo { if(done) { - PromiseInvoke

::_promise.set_value(); + PromiseInvoke::_promise.set_value(); } return false; } }; +template +inline std::future makePromiseOutgoing(bool sync, Obj obj, Fn fn, Args&&... args) +{ + auto outAsync = std::make_shared>(*obj, sync); + (obj->*fn)(outAsync, std::forward(args)...); + return outAsync->getFuture(); +} + +template +inline std::function makeLambdaOutgoing(Re r, E e, S s, Obj obj, Fn fn, Args&&... args) +{ + auto outAsync = std::make_shared>(*obj, std::move(r), std::move(e), std::move(s)); + (obj->*fn)(outAsync, std::forward(args)...); + return [outAsync]() { outAsync->cancel(); }; +} + } #endif diff --git a/cpp/include/Ice/OutgoingAsyncF.h b/cpp/include/Ice/OutgoingAsyncF.h deleted file mode 100644 index f5ae73c9e33..00000000000 --- a/cpp/include/Ice/OutgoingAsyncF.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// - -#ifndef ICE_OUTGOING_ASYNC_F_H -#define ICE_OUTGOING_ASYNC_F_H - -#include -#include - -namespace IceInternal -{ - -class OutgoingAsyncBase; -class OutgoingAsync; -class ProxyOutgoingAsyncBase; -class CommunicatorFlushBatchAsync; - -using OutgoingAsyncBasePtr = ::std::shared_ptr; -using OutgoingAsyncPtr = ::std::shared_ptr; -using ProxyOutgoingAsyncBasePtr = ::std::shared_ptr; -using CommunicatorFlushBatchAsyncPtr = ::std::shared_ptr; - -} - -#endif diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index a92221c6c43..b603d3e275f 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -38,8 +38,6 @@ class ProxyGetConnection; class ProxyFlushBatchAsync; template class OutgoingAsyncT; -template class PromiseOutgoing; -template class LambdaOutgoing; } @@ -841,24 +839,6 @@ class ICE_API ObjectPrx : public Proxy // The constructor used by _fromReference. explicit ObjectPrx(IceInternal::ReferencePtr&&); - - template class P = ::std::promise, typename Obj, typename Fn, typename... Args> - auto _makePromiseOutgoing(bool sync, Obj obj, Fn fn, Args&&... args) const - -> decltype(std::declval>().get_future()) - { - auto outAsync = ::std::make_shared<::IceInternal::PromiseOutgoing, R>>(*this, sync); - (obj->*fn)(outAsync, std::forward(args)...); - return outAsync->getFuture(); - } - - template - ::std::function _makeLambdaOutgoing(Re r, E e, S s, Obj obj, Fn fn, Args&&... args) const - { - auto outAsync = ::std::make_shared<::IceInternal::LambdaOutgoing>(*this, - std::move(r), std::move(e), std::move(s)); - (obj->*fn)(outAsync, std::forward(args)...); - return [outAsync]() { outAsync->cancel(); }; - } /// \endcond private: diff --git a/cpp/include/IceBT/ConnectionInfo.h b/cpp/include/IceBT/ConnectionInfo.h index 7926267420a..a62ede38c92 100644 --- a/cpp/include/IceBT/ConnectionInfo.h +++ b/cpp/include/IceBT/ConnectionInfo.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/IceIAP/ConnectionInfo.h b/cpp/include/IceIAP/ConnectionInfo.h index bd293142299..67acf9ca5bd 100644 --- a/cpp/include/IceIAP/ConnectionInfo.h +++ b/cpp/include/IceIAP/ConnectionInfo.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/include/IceSSL/ConnectionInfo.h b/cpp/include/IceSSL/ConnectionInfo.h index 9d717de5067..bfb21d838f5 100644 --- a/cpp/include/IceSSL/ConnectionInfo.h +++ b/cpp/include/IceSSL/ConnectionInfo.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp index 5624e2a3d1f..16b34716090 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.cpp +++ b/cpp/src/Ice/CollocatedRequestHandler.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include "Ice/OutgoingAsync.h" #include diff --git a/cpp/src/Ice/Communicator.cpp b/cpp/src/Ice/Communicator.cpp index 2789fe178b2..cb0143c16fa 100644 --- a/cpp/src/Ice/Communicator.cpp +++ b/cpp/src/Ice/Communicator.cpp @@ -7,3 +7,26 @@ Ice::Communicator::~Communicator() { } + +void +Ice::Communicator::flushBatchRequests(CompressBatch compress) +{ + flushBatchRequestsAsync(compress).get(); +} + +std::future +Ice::Communicator::flushBatchRequestsAsync(CompressBatch compress) +{ + auto promise = std::make_shared>(); + flushBatchRequestsAsync( + compress, + [promise](std::exception_ptr ex) + { + promise->set_exception(ex); + }, + [promise](bool) + { + promise->set_value(); + }); + return promise->get_future(); +} diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index cd4ca205d8e..fb38737c5fc 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include "Ice/OutgoingAsync.h" #include using namespace std; diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h index c4d15a60c72..bb0860a08f8 100644 --- a/cpp/src/Ice/CommunicatorI.h +++ b/cpp/src/Ice/CommunicatorI.h @@ -8,7 +8,7 @@ #include #include #include -#include +#include "Ice/OutgoingAsync.h" #include @@ -16,7 +16,8 @@ namespace IceInternal { // -// Class for handling Ice::Communicator::begin_flushBatchRequests +// Class for handling Ice::Communicator::flushBatchRequests +// This class needs to be in a public header as it's used by several other classes. // class CommunicatorFlushBatchAsync : public OutgoingAsyncBase { diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp index c9f3019baa4..7def4c973e9 100644 --- a/cpp/src/Ice/ConnectRequestHandler.cpp +++ b/cpp/src/Ice/ConnectRequestHandler.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include "Ice/OutgoingAsync.h" #include #include #include diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index ede824a0de0..df782ee57bc 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -27,6 +27,48 @@ Ice::Connection::~Connection() { } +void +Ice::Connection::flushBatchRequests(CompressBatch compress) +{ + flushBatchRequestsAsync(compress).get(); +} + +std::future +Ice::Connection::flushBatchRequestsAsync(CompressBatch compress) +{ + auto promise = std::make_shared>(); + flushBatchRequestsAsync( + compress, + [promise](std::exception_ptr ex) + { + promise->set_exception(ex); + }, + [promise](bool) + { + promise->set_value(); + }); + return promise->get_future(); +} + +void +Ice::Connection::heartbeat() +{ + heartbeatAsync().get(); +} + +std::future +Ice::Connection::heartbeatAsync() +{ + auto promise = std::make_shared>(); + heartbeatAsync([promise](std::exception_ptr ex) + { promise->set_exception(ex); }, + [promise](bool) + { + promise->set_value(); + }); + return promise->get_future(); +} + Ice::IPConnectionInfo::~IPConnectionInfo() { } diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index cc0ece9eabf..61aa7fd9cde 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h index 969add20387..954f9fcd044 100644 --- a/cpp/src/Ice/ConnectionFactory.h +++ b/cpp/src/Ice/ConnectionFactory.h @@ -37,6 +37,9 @@ class ObjectAdapterI; namespace IceInternal { +class CommunicatorFlushBatchAsync; +using CommunicatorFlushBatchAsyncPtr = ::std::shared_ptr; + template class ThreadPoolMessage; class OutgoingConnectionFactory final : public std::enable_shared_from_this diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index 599bde4855c..5dc3bb18775 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -15,7 +15,6 @@ #include #include // For getThreadPool() and getServantManager(). #include -#include #include #include #include // For RetryException diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index abf6c129c0b..57caebb150a 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include "Ice/OutgoingAsync.h" #include #include #include diff --git a/cpp/src/Ice/FixedRequestHandler.cpp b/cpp/src/Ice/FixedRequestHandler.cpp index e44d9793ef3..1ec2da8e21d 100644 --- a/cpp/src/Ice/FixedRequestHandler.cpp +++ b/cpp/src/Ice/FixedRequestHandler.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include "Ice/OutgoingAsync.h" using namespace std; using namespace Ice; diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h index 8b9600935d8..9b9030ee691 100644 --- a/cpp/src/Ice/ObjectAdapterI.h +++ b/cpp/src/Ice/ObjectAdapterI.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -26,6 +25,14 @@ #include #include +namespace IceInternal +{ + +class CommunicatorFlushBatchAsync; +using CommunicatorFlushBatchAsyncPtr = ::std::shared_ptr; + +} + namespace Ice { diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index ca1abe12f5b..b6a70ed0f8a 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -#include +#include "Ice/OutgoingAsync.h" #include #include #include @@ -481,9 +481,9 @@ ProxyOutgoingAsyncBase::abort(std::exception_ptr ex) } } -ProxyOutgoingAsyncBase::ProxyOutgoingAsyncBase(const ObjectPrx& proxy) : +ProxyOutgoingAsyncBase::ProxyOutgoingAsyncBase(ObjectPrx proxy) : OutgoingAsyncBase(proxy->_getReference()->getInstance()), - _proxy(proxy), + _proxy(std::move(proxy)), _mode(OperationMode::Normal), _cnt(0), _sent(false) @@ -633,9 +633,9 @@ ProxyOutgoingAsyncBase::runTimerTask() } } -OutgoingAsync::OutgoingAsync(const ObjectPrx& proxy, bool synchronous) : - ProxyOutgoingAsyncBase(proxy), - _encoding(getCompatibleEncoding(proxy->_getReference()->getEncoding())), +OutgoingAsync::OutgoingAsync(ObjectPrx proxy, bool synchronous) : + ProxyOutgoingAsyncBase(std::move(proxy)), + _encoding(getCompatibleEncoding(_proxy->_getReference()->getEncoding())), _synchronous(synchronous) { } diff --git a/cpp/src/Ice/ProxyAsync.cpp b/cpp/src/Ice/ProxyAsync.cpp index f181e0dc482..df86050d5e2 100644 --- a/cpp/src/Ice/ProxyAsync.cpp +++ b/cpp/src/Ice/ProxyAsync.cpp @@ -53,7 +53,7 @@ class ProxyFlushBatchAsync : public ProxyOutgoingAsyncBase { public: - ProxyFlushBatchAsync(const Ice::ObjectPrx&); + ProxyFlushBatchAsync(Ice::ObjectPrx); virtual AsyncStatus invokeRemote(const Ice::ConnectionIPtr&, bool, bool); virtual AsyncStatus invokeCollocated(CollocatedRequestHandler*); @@ -72,7 +72,7 @@ class ProxyGetConnection : public ProxyOutgoingAsyncBase { public: - ProxyGetConnection(const Ice::ObjectPrx&); + ProxyGetConnection(Ice::ObjectPrx); virtual AsyncStatus invokeRemote(const Ice::ConnectionIPtr&, bool, bool); virtual AsyncStatus invokeCollocated(CollocatedRequestHandler*); @@ -86,11 +86,11 @@ class ProxyGetConnectionLambda : public ProxyGetConnection, public LambdaInvoke { public: - ProxyGetConnectionLambda(const ObjectPrx& proxy, + ProxyGetConnectionLambda(ObjectPrx proxy, std::function)> response, std::function ex, std::function sent) : - ProxyGetConnection(proxy), LambdaInvoke(std::move(ex), std::move(sent)) + ProxyGetConnection(std::move(proxy)), LambdaInvoke(std::move(ex), std::move(sent)) { _response = [&, response = std::move(response)](bool) { @@ -99,12 +99,11 @@ class ProxyGetConnectionLambda : public ProxyGetConnection, public LambdaInvoke } }; -template -class ProxyGetConnectionPromise : public ProxyGetConnection, public PromiseInvoke

+class ProxyGetConnectionPromise : public ProxyGetConnection, public PromiseInvoke> { public: - ProxyGetConnectionPromise(const ObjectPrx& proxy) : ProxyGetConnection(proxy) + ProxyGetConnectionPromise(ObjectPrx proxy) : ProxyGetConnection(std::move(proxy)) { this->_response = [&](bool) { @@ -117,16 +116,15 @@ class ProxyFlushBatchLambda : public ProxyFlushBatchAsync, public LambdaInvoke { public: - ProxyFlushBatchLambda(const ObjectPrx& proxy, + ProxyFlushBatchLambda(ObjectPrx proxy, std::function ex, std::function sent) : - ProxyFlushBatchAsync(proxy), LambdaInvoke(std::move(ex), std::move(sent)) + ProxyFlushBatchAsync(std::move(proxy)), LambdaInvoke(std::move(ex), std::move(sent)) { } }; -template -class ProxyFlushBatchPromise : public ProxyFlushBatchAsync, public PromiseInvoke

+class ProxyFlushBatchPromise : public ProxyFlushBatchAsync, public PromiseInvoke { public: @@ -189,11 +187,11 @@ class InvokeLambdaOutgoing : public InvokeOutgoingAsyncT, public LambdaInvoke { public: - InvokeLambdaOutgoing(const Ice::ObjectPrx& proxy, + InvokeLambdaOutgoing(Ice::ObjectPrx proxy, std::function response, std::function ex, std::function sent) : - InvokeOutgoingAsyncT(proxy, false), LambdaInvoke(std::move(ex), std::move(sent)) + InvokeOutgoingAsyncT(std::move(proxy), false), LambdaInvoke(std::move(ex), std::move(sent)) { if(response) { @@ -201,7 +199,7 @@ class InvokeLambdaOutgoing : public InvokeOutgoingAsyncT, public LambdaInvoke { if(this->_is.b.empty()) { - response(R { ok, { 0, 0 }}); + response(R { ok, {} }); } else { @@ -212,13 +210,13 @@ class InvokeLambdaOutgoing : public InvokeOutgoingAsyncT, public LambdaInvoke } }; -template -class InvokePromiseOutgoing : public InvokeOutgoingAsyncT, public PromiseInvoke

+template +class InvokePromiseOutgoing : public InvokeOutgoingAsyncT, public PromiseInvoke { public: - InvokePromiseOutgoing(const Ice::ObjectPrx& proxy, bool synchronous) : - InvokeOutgoingAsyncT(proxy, false) + InvokePromiseOutgoing(Ice::ObjectPrx proxy, bool synchronous) : + InvokeOutgoingAsyncT(std::move(proxy), false) { this->_synchronous = synchronous; this->_response = [this](bool ok) @@ -246,7 +244,7 @@ class InvokePromiseOutgoing : public InvokeOutgoingAsyncT, public PromiseInvo } -ProxyFlushBatchAsync::ProxyFlushBatchAsync(const ObjectPrx& proxy) : ProxyOutgoingAsyncBase(proxy) +ProxyFlushBatchAsync::ProxyFlushBatchAsync(ObjectPrx proxy) : ProxyOutgoingAsyncBase(std::move(proxy)) { } @@ -295,7 +293,7 @@ ProxyFlushBatchAsync::invoke(const string& operation) invokeImpl(true); // userThread = true } -ProxyGetConnection::ProxyGetConnection(const ObjectPrx& prx) : ProxyOutgoingAsyncBase(prx) +ProxyGetConnection::ProxyGetConnection(ObjectPrx proxy) : ProxyOutgoingAsyncBase(std::move(proxy)) { } @@ -336,7 +334,7 @@ ProxyGetConnection::invoke(const string& operation) bool Ice::ObjectPrx::ice_isA(const string& typeId, const Ice::Context& context) const { - return _makePromiseOutgoing(true, this, &ObjectPrx::_iceI_isA, typeId, context).get(); + return makePromiseOutgoing(true, this, &ObjectPrx::_iceI_isA, typeId, context).get(); } std::function @@ -347,14 +345,14 @@ Ice::ObjectPrx::ice_isAAsync( std::function sent, const Ice::Context& context) const { - return _makeLambdaOutgoing(std::move(response), std::move(ex), std::move(sent), this, + return makeLambdaOutgoing(std::move(response), std::move(ex), std::move(sent), this, &ObjectPrx::_iceI_isA, typeId, context); } std::future Ice::ObjectPrx::ice_isAAsync(const string& typeId, const Ice::Context& context) const { - return _makePromiseOutgoing(false, this, &ObjectPrx::_iceI_isA, typeId, context); + return makePromiseOutgoing(false, this, &ObjectPrx::_iceI_isA, typeId, context); } void @@ -374,7 +372,7 @@ Ice::ObjectPrx::_iceI_isA(const shared_ptr>& outAsync, void Ice::ObjectPrx::ice_ping(const Ice::Context& context) const { - _makePromiseOutgoing(true, this, &ObjectPrx::_iceI_ping, context).get(); + makePromiseOutgoing(true, this, &ObjectPrx::_iceI_ping, context).get(); } std::function @@ -384,14 +382,14 @@ Ice::ObjectPrx::ice_pingAsync( std::function sent, const Ice::Context& context) const { - return _makeLambdaOutgoing(std::move(response), std::move(ex), std::move(sent), this, + return makeLambdaOutgoing(std::move(response), std::move(ex), std::move(sent), this, &ObjectPrx::_iceI_ping, context); } std::future Ice::ObjectPrx::ice_pingAsync(const Ice::Context& context) const { - return _makePromiseOutgoing(false, this, &ObjectPrx::_iceI_ping, context); + return makePromiseOutgoing(false, this, &ObjectPrx::_iceI_ping, context); } void @@ -403,7 +401,7 @@ Ice::ObjectPrx::_iceI_ping(const shared_ptr>& outAsync, con vector Ice::ObjectPrx::ice_ids(const Ice::Context& context) const { - return _makePromiseOutgoing>(true, this, &ObjectPrx::_iceI_ids, context).get(); + return makePromiseOutgoing>(true, this, &ObjectPrx::_iceI_ids, context).get(); } std::function @@ -413,14 +411,14 @@ Ice::ObjectPrx::ice_idsAsync( std::function sent, const Ice::Context& context) const { - return _makeLambdaOutgoing>(std::move(response), std::move(ex), std::move(sent), + return makeLambdaOutgoing>(std::move(response), std::move(ex), std::move(sent), this, &ObjectPrx::_iceI_ids, context); } std::future> Ice::ObjectPrx::ice_idsAsync(const Ice::Context& context) const { - return _makePromiseOutgoing, std::promise>(false, this, &ObjectPrx::_iceI_ids, context); + return makePromiseOutgoing>(false, this, &ObjectPrx::_iceI_ids, context); } void @@ -439,7 +437,7 @@ Ice::ObjectPrx::_iceI_ids(const shared_ptr>>& outA string Ice::ObjectPrx::ice_id(const Ice::Context& context) const { - return _makePromiseOutgoing(true, this, &ObjectPrx::_iceI_id, context).get(); + return makePromiseOutgoing(true, this, &ObjectPrx::_iceI_id, context).get(); } std::function @@ -448,14 +446,14 @@ Ice::ObjectPrx::ice_idAsync(std::function response, std::function sent, const Ice::Context& context) const { - return _makeLambdaOutgoing(std::move(response), std::move(ex), std::move(sent), this, + return makeLambdaOutgoing(std::move(response), std::move(ex), std::move(sent), this, &ObjectPrx::_iceI_id, context); } std::future Ice::ObjectPrx::ice_idAsync(const Ice::Context& context) const { - return _makePromiseOutgoing(false, this, &ObjectPrx::_iceI_id, context); + return makePromiseOutgoing(false, this, &ObjectPrx::_iceI_id, context); } void @@ -520,8 +518,7 @@ bool Ice::ObjectPrx::ice_invoke(const string &operation, vector &outParams, const Ice::Context &context) const { - using Outgoing = InvokePromiseOutgoing< - std::promise>>, std::tuple>>; + using Outgoing = InvokePromiseOutgoing>>; auto outAsync = std::make_shared(*this, true); outAsync->invoke(operation, mode, inParams, context); auto result = outAsync->getFuture().get(); @@ -537,7 +534,7 @@ Ice::ObjectPrx::ice_invokeAsync(const string &operation, const Ice::Context &context) const { using Outgoing = - ::IceInternal::InvokePromiseOutgoing>>, ::std::tuple>>; + ::IceInternal::InvokePromiseOutgoing<::std::tuple>>; auto outAsync = ::std::make_shared(*this, false); outAsync->invoke(operation, mode, inParams, context); return outAsync->getFuture(); @@ -590,8 +587,7 @@ Ice::ObjectPrx::ice_getConnectionAsync(std::function> Ice::ObjectPrx::ice_getConnectionAsync() const { - using PromiseOutgoing = ProxyGetConnectionPromise>>; - auto outAsync = std::make_shared(*this); + auto outAsync = std::make_shared(*this); _iceI_getConnection(outAsync); return outAsync->getFuture(); } @@ -633,8 +629,7 @@ std::future Ice::ObjectPrx::ice_flushBatchRequestsAsync() const { if (_reference->isBatch()) { - using PromiseOutgoing = ProxyFlushBatchPromise>; - auto outAsync = std::make_shared(*this); + auto outAsync = std::make_shared(*this); _iceI_flushBatchRequests(outAsync); return outAsync->getFuture(); } diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp index 1469aca3bbf..680a53d8fac 100644 --- a/cpp/src/Ice/ProxyFactory.cpp +++ b/cpp/src/Ice/ProxyFactory.cpp @@ -15,7 +15,6 @@ #include #include #include -#include using namespace std; using namespace Ice; diff --git a/cpp/src/Ice/RequestHandler.h b/cpp/src/Ice/RequestHandler.h index 51859575e19..37f053c1817 100644 --- a/cpp/src/Ice/RequestHandler.h +++ b/cpp/src/Ice/RequestHandler.h @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -21,6 +20,12 @@ class LocalException; namespace IceInternal { +class OutgoingAsyncBase; +class ProxyOutgoingAsyncBase; + +using OutgoingAsyncBasePtr = std::shared_ptr; +using ProxyOutgoingAsyncBasePtr = std::shared_ptr; + // // An exception wrapper, which is used to notify that the request // handler should be cleared and the invocation retried. diff --git a/cpp/src/Ice/RetryQueue.cpp b/cpp/src/Ice/RetryQueue.cpp index 7ab3db18b85..ba3d0c2ab80 100644 --- a/cpp/src/Ice/RetryQueue.cpp +++ b/cpp/src/Ice/RetryQueue.cpp @@ -3,7 +3,7 @@ // #include -#include +#include "Ice/OutgoingAsync.h" #include #include #include diff --git a/cpp/src/Ice/RetryQueue.h b/cpp/src/Ice/RetryQueue.h index b9ebb573f26..d013dd24433 100644 --- a/cpp/src/Ice/RetryQueue.h +++ b/cpp/src/Ice/RetryQueue.h @@ -7,7 +7,6 @@ #include #include -#include #include #include // For CancellationHandler @@ -16,6 +15,12 @@ namespace IceInternal { +class OutgoingAsyncBase; +class ProxyOutgoingAsyncBase; + +using OutgoingAsyncBasePtr = std::shared_ptr; +using ProxyOutgoingAsyncBasePtr = std::shared_ptr; + class RetryTask : public IceUtil::TimerTask, public CancellationHandler, public std::enable_shared_from_this diff --git a/cpp/src/IceBox/Service.cpp b/cpp/src/IceBox/Service.cpp index 4206957a6b0..a5398b1f6d8 100644 --- a/cpp/src/IceBox/Service.cpp +++ b/cpp/src/IceBox/Service.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/src/IceGridLib/PluginFacade.cpp b/cpp/src/IceGridLib/PluginFacade.cpp index 54c0d08b304..efbe4cf5b45 100644 --- a/cpp/src/IceGridLib/PluginFacade.cpp +++ b/cpp/src/IceGridLib/PluginFacade.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/src/IceStorm/Instrumentation.cpp b/cpp/src/IceStorm/Instrumentation.cpp index be2666d8f5c..210a7438d8d 100644 --- a/cpp/src/IceStorm/Instrumentation.cpp +++ b/cpp/src/IceStorm/Instrumentation.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index f43a6bd4e79..831e8d5b047 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -729,7 +729,6 @@ Slice::Gen::generate(const UnitPtr& p) C << _include << '/'; } C << _base << "." << _headerExtension << ">"; - C << "\n#include "; H << "\n#include "; @@ -738,8 +737,6 @@ Slice::Gen::generate(const UnitPtr& p) H << "\n#include "; } - C << "\n#include "; - StringList includes = p->includeFiles(); for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q) @@ -797,6 +794,12 @@ Slice::Gen::generate(const UnitPtr& p) dc->setMetaData(globalMetaData); } + if(!dc->hasMetaDataDirective("cpp:no-default-include")) + { + // We need OutgoingAsync.h only to implement proxies, but for simplicity, we include it all the time. + C << "\n#include "; + } + // // Disable shadow warnings in .cpp file // @@ -2091,7 +2094,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << "auto _result = "; } - C << "_makePromiseOutgoing<" << futureT << ">"; + C << "::IceInternal::makePromiseOutgoing<" << futureT << ">"; C << spar << "true, this" << "&" + interface->name() + "Prx::_iceI_" + name; for (ParamDeclList::const_iterator q = inParams.begin(); q != inParams.end(); ++q) @@ -2135,7 +2138,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << scoped << name << "Async" << spar << inParamsImplDecl << "const ::Ice::Context& context" << epar << " const"; C << sb; - C << nl << "return _makePromiseOutgoing<" << futureT << ", ::std::promise>" << spar; + C << nl << "return ::IceInternal::makePromiseOutgoing<" << futureT << ">" << spar; C << "false, this" << string("&" + interface->name() + "Prx::_iceI_" + name); for(ParamDeclList::const_iterator q = inParams.begin(); q != inParams.end(); ++q) { @@ -2299,7 +2302,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << epar << ";" << eb << ";"; } - C << nl << "return _makeLambdaOutgoing<" << futureT << ">" << spar; + C << nl << "return ::IceInternal::makeLambdaOutgoing<" << futureT << ">" << spar; C << "std::move(" + (futureOutParams.size() > 1 ? string("_responseCb") : "response") + ")" << "std::move(ex)"