diff options
-rw-r--r-- | cpp/include/Ice/Object.h | 6 | ||||
-rw-r--r-- | cpp/include/Ice/Proxy.h | 5 | ||||
-rw-r--r-- | cpp/src/Ice/Object.cpp | 36 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 127 | ||||
-rw-r--r-- | cpp/src/IceLocatorDiscovery/PluginI.cpp | 271 | ||||
-rw-r--r-- | cpp/test/Ice/invoke/AllTests.cpp | 4 | ||||
-rw-r--r-- | cpp/test/Ice/invoke/BlobjectI.cpp | 10 | ||||
-rw-r--r-- | cpp/test/Ice/invoke/BlobjectI.h | 6 | ||||
-rw-r--r-- | cpp/test/Makefile | 3 | ||||
-rw-r--r-- | cpp/test/Makefile.mak | 3 |
10 files changed, 403 insertions, 68 deletions
diff --git a/cpp/include/Ice/Object.h b/cpp/include/Ice/Object.h index 8456e6dd008..4598cccde4e 100644 --- a/cpp/include/Ice/Object.h +++ b/cpp/include/Ice/Object.h @@ -184,7 +184,8 @@ public: #ifdef ICE_CPP11_MAPPING virtual void ice_invoke_async(std::vector<Byte>, - std::function<void (bool, const std::vector<Byte>&)>, + std::function<void (bool, std::vector<Byte>)>, + std::function<void (std::exception_ptr)>, const Current&) = 0; #else virtual void ice_invoke_async(const AMD_Object_ice_invokePtr&, const std::vector<Byte>&, const Current&) = 0; @@ -198,7 +199,8 @@ public: #ifdef ICE_CPP11_MAPPING virtual void ice_invoke_async(std::pair<const Byte*, const Byte*>, - std::function<void (bool, const std::pair<const Byte*, const Byte*>&)>, + std::function<void (bool, std::pair<const Byte*, const Byte*>)>, + std::function<void (std::exception_ptr)>, const Current&) = 0; #else virtual void ice_invoke_async(const AMD_Object_ice_invokePtr&, const std::pair<const Byte*, const Byte*>&, diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index 70cc6e3a4cd..85b58b4eb19 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -242,7 +242,7 @@ public: const ::std::string&, ::Ice::OperationMode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, - ::std::function<void (bool, ::std::vector<::Ice::Byte>)> response, + ::std::function<void (bool, ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>)> response, ::std::function<void (::std::exception_ptr)> exception = nullptr, ::std::function<void (bool)> sent = nullptr, const ::Ice::Context& context = ::Ice::noExplicitContext); @@ -315,7 +315,8 @@ public: ::std::function<void ()> ice_getConnection_async( ::std::function<void (::std::shared_ptr<::Ice::Connection>)> response, - ::std::function<void (::std::exception_ptr)> exception = nullptr); + ::std::function<void (::std::exception_ptr)> exception = nullptr, + ::std::function<void (bool)> sent = nullptr); template<template<typename> class P = std::promise> diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index 637fa0977ad..c7af240dcac 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -434,6 +434,24 @@ Ice::BlobjectAsync::__dispatch(Incoming& in, const Current& current) async->__response(); } }, + [async](exception_ptr e) + { + if(e) + { + try + { + rethrow_exception(e); + } + catch(const exception& ex) + { + async->ice_exception(ex); + } + } + else + { + async->ice_exception(); + } + }, current); } catch(const ::std::exception& ex) @@ -491,6 +509,24 @@ Ice::BlobjectArrayAsync::__dispatch(Incoming& in, const Current& current) async->__response(); } }, + [async](exception_ptr e) + { + if(e) + { + try + { + rethrow_exception(e); + } + catch(const exception& ex) + { + async->ice_exception(ex); + } + } + else + { + async->ice_exception(); + } + }, current); } catch(const ::std::exception& ex) diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 3c9b2905aec..ec185e9d7de 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -247,7 +247,8 @@ Ice::ObjectPrx::ice_ids_async(function<void (vector<string>)> response, function<void ()> Ice::ObjectPrx::ice_getConnection_async( function<void (shared_ptr<::Ice::Connection>)> response, - function<void (exception_ptr)> exception) + function<void (exception_ptr)> exception, + function<void (bool)> sent) { class ConnectionCallback : public CallbackBase @@ -256,18 +257,26 @@ Ice::ObjectPrx::ice_getConnection_async( ConnectionCallback(function<void (shared_ptr<::Ice::Connection>)> response, function<void (exception_ptr)> exception, + function<void (bool)> sent, shared_ptr<ObjectPrx> proxy) : _response(move(response)), _exception(move(exception)), + _sent(move(sent)), _proxy(move(proxy)) { } - virtual void sent(const AsyncResultPtr&) const {} + virtual void sent(const AsyncResultPtr& result) const + { + if(_sent) + { + _sent(result->sentSynchronously()); + } + } virtual bool hasSentCallback() const { - return false; + return _sent != nullptr; } @@ -296,12 +305,13 @@ Ice::ObjectPrx::ice_getConnection_async( function<void (shared_ptr<::Ice::Connection>)> _response; function<void (exception_ptr)> _exception; + function<void (bool)> _sent; shared_ptr<ObjectPrx> _proxy; }; auto result = make_shared<ProxyGetConnection>(shared_from_this(), ice_getConnection_name, - make_shared<ConnectionCallback>(move(response), move(exception), shared_from_this())); + make_shared<ConnectionCallback>(move(response), move(exception), move(sent), shared_from_this())); try { result->invoke(); @@ -414,7 +424,7 @@ bool Ice::ObjectPrx::ice_invoke(const string& operation, ::Ice::OperationMode mode, const vector<::Ice::Byte>& inParams, - vector<::Ice::Byte>& pOutParams, + vector<::Ice::Byte>& outParams, const ::Ice::Context& context) { switch(_reference->getMode()) @@ -423,9 +433,9 @@ Ice::ObjectPrx::ice_invoke(const string& operation, { promise<bool> p; ice_invoke_async(operation, mode, inParams, - [&](bool ok, vector<::Ice::Byte> outParams) + [&](bool ok, vector<::Ice::Byte> outEncaps) { - pOutParams = move(outParams); + outParams = move(outEncaps); p.set_value(ok); }, [&](exception_ptr ex) @@ -464,7 +474,7 @@ bool Ice::ObjectPrx::ice_invoke(const string& operation, ::Ice::OperationMode mode, const pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, - vector<::Ice::Byte>& pOutParams, + vector<::Ice::Byte>& outParams, const ::Ice::Context& context) { switch(_reference->getMode()) @@ -473,9 +483,9 @@ Ice::ObjectPrx::ice_invoke(const string& operation, { promise<bool> p; ice_invoke_async(operation, mode, inParams, - [&](bool ok, vector<::Ice::Byte> outParams) + [&](bool ok, pair<const ::Ice::Byte*, const ::Ice::Byte*> outEncaps) { - pOutParams = move(outParams); + vector<Byte>(outEncaps.first, outEncaps.second).swap(outParams); p.set_value(ok); }, [&](exception_ptr ex) @@ -529,14 +539,93 @@ Ice::ObjectPrx::ice_invoke_async(const string& operation, inPair.first = &inEncaps[0]; inPair.second = inPair.first + inEncaps.size(); } - return ice_invoke_async(operation, mode, inPair, move(response), move(exception), move(sent), context); + + class InvokeCallback : public CallbackBase + { + public: + + InvokeCallback(function<void (bool, vector<::Ice::Byte>)> response, + function<void (exception_ptr)> exception, + function<void (bool)> sent, + shared_ptr<ObjectPrx> proxy) : + _response(move(response)), + _exception(move(exception)), + _sent(move(sent)), + _proxy(move(proxy)) + { + } + + virtual void sent(const AsyncResultPtr& result) const + { + if(_sent) + { + _sent(result->sentSynchronously()); + } + } + + virtual bool hasSentCallback() const + { + return _sent != nullptr; + } + + virtual void + completed(const ::Ice::AsyncResultPtr& result) const + { + try + { + AsyncResult::__check(result, _proxy.get(), ice_invoke_name); + bool ok = result->__wait(); + if(_proxy->_reference->getMode() == Reference::ModeTwoway) + { + const Byte* v; + Int sz; + result->__readParamEncaps(v, sz); + if(_response) + { + _response(ok, vector<Byte>(v, v + sz)); + } + } + } + catch(const ::Ice::Exception&) + { + if(_exception) + { + _exception(current_exception()); + } + } + } + + private: + + function<void (bool, vector<::Ice::Byte>)> _response; + function<void (exception_ptr)> _exception; + function<void (bool)> _sent; + shared_ptr<ObjectPrx> _proxy; + }; + auto result = make_shared<OutgoingAsync>(shared_from_this(), ice_invoke_name, + make_shared<InvokeCallback>(move(response), move(exception), move(sent), shared_from_this())); + try + { + result->prepare(operation, mode, context); + result->writeParamEncaps(inPair.first, inEncaps.size()); + result->invoke(); + } + catch(const Exception& ex) + { + result->abort(ex); + } + + return [result]() + { + result->cancel(); + }; } function<void ()> Ice::ObjectPrx::ice_invoke_async(const string& operation, ::Ice::OperationMode mode, - const pair<const ::Ice::Byte*, const ::Ice::Byte*>& inEncaps, - function<void (bool, vector<::Ice::Byte>)> response, + const pair<const Byte*, const Byte*>& inEncaps, + function<void (bool, pair<const Byte*, const Byte*>)> response, function<void (exception_ptr)> exception, function<void (bool)> sent, const ::Ice::Context& context) @@ -545,7 +634,7 @@ Ice::ObjectPrx::ice_invoke_async(const string& operation, { public: - InvokeCallback(function<void (bool, vector<::Ice::Byte>)> response, + InvokeCallback(function<void (bool, pair<const Byte*, const Byte*>)> response, function<void (exception_ptr)> exception, function<void (bool)> sent, shared_ptr<ObjectPrx> proxy) : @@ -569,7 +658,6 @@ Ice::ObjectPrx::ice_invoke_async(const string& operation, return _sent != nullptr; } - virtual void completed(const ::Ice::AsyncResultPtr& result) const { @@ -579,12 +667,13 @@ Ice::ObjectPrx::ice_invoke_async(const string& operation, bool ok = result->__wait(); if(_proxy->_reference->getMode() == Reference::ModeTwoway) { - const Byte* v; + pair<const Byte*, const Byte*> v; Int sz; - result->__readParamEncaps(v, sz); + result->__readParamEncaps(v.first, sz); + v.second = v.first + sz; if(_response) { - _response(ok, vector<Byte>(v, v + sz)); + _response(ok, move(v)); } } } @@ -599,7 +688,7 @@ Ice::ObjectPrx::ice_invoke_async(const string& operation, private: - function<void (bool, vector<::Ice::Byte>)> _response; + function<void (bool, pair<const Byte*, const Byte*>)> _response; function<void (exception_ptr)> _exception; function<void (bool)> _sent; shared_ptr<ObjectPrx> _proxy; diff --git a/cpp/src/IceLocatorDiscovery/PluginI.cpp b/cpp/src/IceLocatorDiscovery/PluginI.cpp index bf30aa4cf8e..5207a096c9c 100644 --- a/cpp/src/IceLocatorDiscovery/PluginI.cpp +++ b/cpp/src/IceLocatorDiscovery/PluginI.cpp @@ -54,10 +54,26 @@ namespace class LocatorI; // Forward declaration -class Request : public IceUtil::Shared +class Request : public Ice::EnableSharedFromThis<Request> { public: +#ifdef ICE_CPP11_MAPPING + Request(LocatorI* locator, + const string& operation, + Ice::OperationMode mode, + const pair<const Ice::Byte*, const Ice::Byte*>& inParams, + const Ice::Context& ctx, + function<void (bool, const pair<const Ice::Byte*, const Ice::Byte*>&)> responseCB, + function<void (exception_ptr)> exceptionCB) : + _locator(locator), + _operation(operation), + _mode(mode), + _context(ctx), + _inParams(inParams.first, inParams.second), + _responseCB(move(responseCB)), + _exceptionCB(move(exceptionCB)) +#else Request(LocatorI* locator, const string& operation, Ice::OperationMode mode, @@ -70,10 +86,11 @@ public: _context(ctx), _inParams(inParams.first, inParams.second), _amdCB(amdCB) +#endif { } - void invoke(const Ice::LocatorPrx&); + void invoke(const Ice::LocatorPrxPtr&); void response(const bool, const pair<const Ice::Byte*, const Ice::Byte*>&); void exception(const Ice::Exception&); @@ -84,31 +101,47 @@ protected: const Ice::OperationMode _mode; const Ice::Context _context; const Ice::ByteSeq _inParams; +#ifdef ICE_CPP11_MAPPING + function<void (bool, const pair<const Ice::Byte*, const Ice::Byte*>&)> _responseCB; + function<void (exception_ptr)> _exceptionCB; + exception_ptr _exception; +#else const Ice::AMD_Object_ice_invokePtr _amdCB; - - Ice::LocatorPrx _locatorPrx; IceUtil::UniquePtr<Ice::Exception> _exception; +#endif + + Ice::LocatorPrxPtr _locatorPrx; }; -typedef IceUtil::Handle<Request> RequestPtr; +ICE_DEFINE_PTR(RequestPtr, Request); -class LocatorI : public Ice::BlobjectArrayAsync, private IceUtil::TimerTask, private IceUtil::Monitor<IceUtil::Mutex> +class LocatorI : public Ice::BlobjectArrayAsync, + public IceUtil::TimerTask, + private IceUtil::Monitor<IceUtil::Mutex>, + public Ice::EnableSharedFromThis<LocatorI> { public: - LocatorI(const LookupPrx&, const Ice::PropertiesPtr&, const string&, const Ice::LocatorPrx&); - void setLookupReply(const LookupReplyPrx&); + LocatorI(const LookupPrxPtr&, const Ice::PropertiesPtr&, const string&, const Ice::LocatorPrxPtr&); + void setLookupReply(const LookupReplyPrxPtr&); +#ifdef ICE_CPP11_MAPPING + virtual void ice_invoke_async(pair<const Ice::Byte*, const Ice::Byte*>, + function<void (bool, const pair<const Ice::Byte*, const Ice::Byte*>&)>, + function<void (exception_ptr)>, + const Ice::Current&); +#else virtual void ice_invoke_async(const Ice::AMD_Object_ice_invokePtr&, const pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&); +#endif - void foundLocator(const Ice::LocatorPrx&); - void invoke(const Ice::LocatorPrx&, const RequestPtr&); + void foundLocator(const Ice::LocatorPrxPtr&); + void invoke(const Ice::LocatorPrxPtr&, const RequestPtr&); private: virtual void runTimerTask(); - const LookupPrx _lookup; + const LookupPrxPtr _lookup; const IceUtil::Time _timeout; const int _retryCount; const IceUtil::Time _retryDelay; @@ -116,15 +149,15 @@ private: string _instanceName; bool _warned; - LookupReplyPrx _lookupReply; - Ice::LocatorPrx _locator; - Ice::LocatorPrx _voidLocator; + LookupReplyPrxPtr _lookupReply; + Ice::LocatorPrxPtr _locator; + Ice::LocatorPrxPtr _voidLocator; IceUtil::Time _nextRetry; int _pendingRetryCount; vector<RequestPtr> _pendingRequests; }; -typedef IceUtil::Handle<LocatorI> LocatorIPtr; +ICE_DEFINE_PTR(LocatorIPtr, LocatorI); class LookupReplyI : public LookupReply { @@ -134,7 +167,7 @@ public: { } - virtual void foundLocator(const Ice::LocatorPrx&, const Ice::Current&); + virtual void foundLocator(ICE_IN(Ice::LocatorPrxPtr), const Ice::Current&); private: @@ -155,6 +188,25 @@ class VoidLocatorI : public Ice::Locator { public: +#ifdef ICE_CPP11_MAPPING + virtual void + findObjectById_async(::Ice::Identity, + function<void (const shared_ptr<::Ice::ObjectPrx>&)> response, + function<void (exception_ptr)>, + const Ice::Current&) const + { + response(nullptr); + } + + virtual void + findAdapterById_async(string, + function<void (const shared_ptr<::Ice::ObjectPrx>&)> response, + function<void (exception_ptr)>, + const Ice::Current&) const + { + response(nullptr); + } +#else virtual void findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& amdCB, const Ice::Identity&, @@ -170,11 +222,12 @@ public: { amdCB->ice_response(0); } +#endif - virtual Ice::LocatorRegistryPrx + virtual Ice::LocatorRegistryPrxPtr getRegistry(const Ice::Current&) const { - return 0; + return ICE_NULLPTR; } }; @@ -237,17 +290,40 @@ PluginI::initialize() lookupEndpoints = os.str(); } - Ice::ObjectPrx lookupPrx = _communicator->stringToProxy("IceLocatorDiscovery/Lookup -d:" + lookupEndpoints); + Ice::ObjectPrxPtr lookupPrx = _communicator->stringToProxy("IceLocatorDiscovery/Lookup -d:" + lookupEndpoints); lookupPrx = lookupPrx->ice_collocationOptimized(false); // No collocation optimization for the multicast proxy! try { // Ensure we can establish a connection to the multicast proxy // but don't block. +#ifdef ICE_CPP11_MAPPING + promise<bool> sent; + promise<void> completed; + + lookupPrx->ice_getConnection_async( + [&](shared_ptr<Ice::Connection>) + { + completed.set_value(); + }, + [&](exception_ptr ex) + { + completed.set_exception(ex); + }, + [&](bool sentSynchronously) + { + sent.set_value(sentSynchronously); + }); + if(sent.get_future().get()) + { + completed.get_future().get(); + } +#else Ice::AsyncResultPtr result = lookupPrx->begin_ice_getConnection(); if(result->sentSynchronously()) { lookupPrx->end_ice_getConnection(result); } +#endif } catch(const Ice::LocalException& ex) { @@ -258,17 +334,17 @@ PluginI::initialize() throw Ice::PluginInitializationException(__FILE__, __LINE__, os.str()); } - Ice::LocatorPrx voidLocator = Ice::LocatorPrx::uncheckedCast(_locatorAdapter->addWithUUID(new VoidLocatorI())); + Ice::LocatorPrxPtr voidLocator = ICE_UNCHECKED_CAST(Ice::LocatorPrx, _locatorAdapter->addWithUUID(ICE_MAKE_SHARED(VoidLocatorI))); string instanceName = properties->getProperty("IceLocatorDiscovery.InstanceName"); Ice::Identity id; id.name = "Locator"; id.category = !instanceName.empty() ? instanceName : IceUtil::generateUUID(); - LocatorIPtr locator = new LocatorI(LookupPrx::uncheckedCast(lookupPrx), properties, instanceName, voidLocator); - _communicator->setDefaultLocator(Ice::LocatorPrx::uncheckedCast(_locatorAdapter->add(locator, id))); + LocatorIPtr locator = ICE_MAKE_SHARED(LocatorI, ICE_UNCHECKED_CAST(LookupPrx, lookupPrx), properties, instanceName, voidLocator); + _communicator->setDefaultLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, _locatorAdapter->add(locator, id))); - Ice::ObjectPrx lookupReply = _replyAdapter->addWithUUID(new LookupReplyI(locator))->ice_datagram(); - locator->setLookupReply(LookupReplyPrx::uncheckedCast(lookupReply)); + Ice::ObjectPrxPtr lookupReply = _replyAdapter->addWithUUID(ICE_MAKE_SHARED(LookupReplyI, locator))->ice_datagram(); + locator->setLookupReply(ICE_UNCHECKED_CAST(LookupReplyPrx, lookupReply)); _replyAdapter->activate(); _locatorAdapter->activate(); @@ -282,8 +358,55 @@ PluginI::destroy() } void -Request::invoke(const Ice::LocatorPrx& l) +Request::invoke(const Ice::LocatorPrxPtr& l) { +#ifdef ICE_CPP11_MAPPING + if(l != _locatorPrx) + { + _locatorPrx = l; + try + { + l->ice_invoke_async(_operation, _mode, _inParams, + [self = shared_from_this()](bool ok, vector<Ice::Byte> outParams) + { + pair<const Ice::Byte*, const Ice::Byte*> outPair; + if(outParams.empty()) + { + outPair.first = outPair.second = 0; + } + else + { + outPair.first = &outParams[0]; + outPair.second = outPair.first + outParams.size(); + } + self->response(ok, outPair); + }, + [self = shared_from_this()](exception_ptr e) + { + try + { + rethrow_exception(e); + } + catch(const Ice::Exception& ex) + { + self->exception(ex); + } + }, + nullptr, + _context); + } + catch(const Ice::LocalException& ex) + { + exception(ex); + } + } + else + { + assert(_exception); // Don't retry if the proxy didn't change + _exceptionCB(_exception); + } + +#else if(l != _locatorPrx) { _locatorPrx = l; @@ -302,17 +425,74 @@ Request::invoke(const Ice::LocatorPrx& l) assert(_exception.get()); // Don't retry if the proxy didn't change _amdCB->ice_exception(*_exception.get()); } +#endif } void Request::response(bool ok, const pair<const Ice::Byte*, const Ice::Byte*>& outParams) { +#ifdef ICE_CPP11_MAPPING + _responseCB(ok, outParams); +#else _amdCB->ice_response(ok, outParams); +#endif } void Request::exception(const Ice::Exception& ex) { +#ifdef ICE_CPP11_MAPPING + try + { + ex.ice_throw(); + } + catch(const Ice::RequestFailedException&) + { + _exceptionCB(current_exception()); + } + catch(const Ice::UnknownException&) + { + _exceptionCB(current_exception()); + } + catch(const Ice::NoEndpointException&) + { + try + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + catch(...) + { + _exceptionCB(current_exception()); + } + } + catch(const Ice::CommunicatorDestroyedException&) + { + try + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + catch(...) + { + _exceptionCB(current_exception()); + } + } + catch(const Ice::ObjectAdapterDeactivatedException&) + { + try + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + catch(...) + { + _exceptionCB(current_exception()); + } + } + catch(const Ice::Exception&) + { + _exception = current_exception(); + _locator->invoke(_locatorPrx, shared_from_this()); // Retry with new locator proxy + } +#else try { ex.ice_throw(); @@ -340,14 +520,15 @@ Request::exception(const Ice::Exception& ex) catch(const Ice::Exception&) { _exception.reset(ex.ice_clone()); - _locator->invoke(_locatorPrx, this); // Retry with new locator proxy + _locator->invoke(_locatorPrx, shared_from_this()); // Retry with new locator proxy } +#endif } -LocatorI::LocatorI(const LookupPrx& lookup, +LocatorI::LocatorI(const LookupPrxPtr& lookup, const Ice::PropertiesPtr& p, const string& instanceName, - const Ice::LocatorPrx& voidLocator) : + const Ice::LocatorPrxPtr& voidLocator) : _lookup(lookup), _timeout(IceUtil::Time::milliSeconds(p->getPropertyAsIntWithDefault("IceLocatorDiscovery.Timeout", 300))), _retryCount(p->getPropertyAsIntWithDefault("IceLocatorDiscovery.RetryCount", 3)), @@ -362,11 +543,22 @@ LocatorI::LocatorI(const LookupPrx& lookup, } void -LocatorI::setLookupReply(const LookupReplyPrx& lookupReply) +LocatorI::setLookupReply(const LookupReplyPrxPtr& lookupReply) { _lookupReply = lookupReply; } +#ifdef ICE_CPP11_MAPPING +void +LocatorI::ice_invoke_async(pair<const Ice::Byte*, const Ice::Byte*> inParams, + function<void (bool, const pair<const Ice::Byte*, const Ice::Byte*>&)> responseCB, + function<void (exception_ptr)> exceptionCB, + const Ice::Current& current) +{ + invoke(nullptr, make_shared<Request>(this, current.operation, current.mode, inParams, current.ctx, + move(responseCB), move(exceptionCB))); +} +#else void LocatorI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& amdCB, const pair<const Ice::Byte*, const Ice::Byte*>& inParams, @@ -374,9 +566,10 @@ LocatorI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& amdCB, { invoke(0, new Request(this, current.operation, current.mode, inParams, current.ctx, amdCB)); } +#endif void -LocatorI::foundLocator(const Ice::LocatorPrx& locator) +LocatorI::foundLocator(const Ice::LocatorPrxPtr& locator) { Lock sync(*this); if(!locator || (!_instanceName.empty() && locator->ice_getIdentity().category != _instanceName)) @@ -407,7 +600,7 @@ LocatorI::foundLocator(const Ice::LocatorPrx& locator) if(_pendingRetryCount > 0) // No need to retry, we found a locator. { - _timer->cancel(this); + _timer->cancel(shared_from_this()); _pendingRetryCount = 0; } @@ -460,7 +653,7 @@ LocatorI::foundLocator(const Ice::LocatorPrx& locator) } void -LocatorI::invoke(const Ice::LocatorPrx& locator, const RequestPtr& request) +LocatorI::invoke(const Ice::LocatorPrxPtr& locator, const RequestPtr& request) { Lock sync(*this); if(_locator && _locator != locator) @@ -482,8 +675,12 @@ LocatorI::invoke(const Ice::LocatorPrx& locator, const RequestPtr& request) _pendingRetryCount = _retryCount; try { +#ifdef ICE_CPP11_MAPPING + _lookup->findLocator_async(_instanceName, _lookupReply); // Send multicast request. +#else _lookup->begin_findLocator(_instanceName, _lookupReply); // Send multicast request. - _timer->schedule(this, _timeout); +#endif + _timer->schedule(shared_from_this(), _timeout); } catch(const Ice::LocalException&) { @@ -506,8 +703,12 @@ LocatorI::runTimerTask() { try { +#ifdef ICE_CPP11_MAPPING + _lookup->findLocator_async(_instanceName, _lookupReply); // Send multicast request. +#else _lookup->begin_findLocator(_instanceName, _lookupReply); // Send multicast request. - _timer->schedule(this, _timeout); +#endif + _timer->schedule(shared_from_this(), _timeout); return; } catch(const Ice::LocalException&) @@ -525,7 +726,7 @@ LocatorI::runTimerTask() } void -LookupReplyI::foundLocator(const Ice::LocatorPrx& locator, const Ice::Current&) +LookupReplyI::foundLocator(ICE_IN(Ice::LocatorPrxPtr) locator, const Ice::Current&) { _locator->foundLocator(locator); } diff --git a/cpp/test/Ice/invoke/AllTests.cpp b/cpp/test/Ice/invoke/AllTests.cpp index 0386e04fc84..5b4f559067a 100644 --- a/cpp/test/Ice/invoke/AllTests.cpp +++ b/cpp/test/Ice/invoke/AllTests.cpp @@ -448,9 +448,9 @@ allTests(const Ice::CommunicatorPtr& communicator) pair<const ::Ice::Byte*, const ::Ice::Byte*> inPair(&inEncaps[0], &inEncaps[0] + inEncaps.size()); cl->ice_invoke_async("opString", OperationMode::Normal, inPair, - [&](bool ok, vector<Ice::Byte> outParams) + [&](bool ok, pair<const Ice::Byte*, const Ice::Byte*> outParams) { - outEncaps = move(outParams); + vector<Ice::Byte>(outParams.first, outParams.second).swap(outEncaps); completed.set_value(ok); }, [&](exception_ptr ex) diff --git a/cpp/test/Ice/invoke/BlobjectI.cpp b/cpp/test/Ice/invoke/BlobjectI.cpp index 68e18223365..6ec24555023 100644 --- a/cpp/test/Ice/invoke/BlobjectI.cpp +++ b/cpp/test/Ice/invoke/BlobjectI.cpp @@ -97,18 +97,20 @@ BlobjectArrayI::ice_invoke(const pair<const Ice::Byte*, const Ice::Byte*>& inEnc #ifdef ICE_CPP11_MAPPING void BlobjectAsyncI::ice_invoke_async(vector<Ice::Byte> inEncaps, - function<void (bool, const vector<Ice::Byte>&)> response, + function<void (bool, vector<Ice::Byte>)> response, + function<void (exception_ptr)>, const Ice::Current& current) { Ice::InputStreamPtr in = Ice::createInputStream(current.adapter->getCommunicator(), inEncaps); vector<Ice::Byte> outEncaps; bool ok = invokeInternal(in, outEncaps, current); - response(ok, outEncaps); + response(ok, move(outEncaps)); } void BlobjectArrayAsyncI::ice_invoke_async(pair<const Ice::Byte*, const Ice::Byte*> inEncaps, - function<void (bool, const pair<const Ice::Byte*, const Ice::Byte*>&)> response, + function<void (bool, pair<const Ice::Byte*, const Ice::Byte*>)> response, + function<void (exception_ptr)>, const Ice::Current& current) { Ice::InputStreamPtr in = Ice::createInputStream(current.adapter->getCommunicator(), inEncaps); @@ -124,7 +126,7 @@ BlobjectArrayAsyncI::ice_invoke_async(pair<const Ice::Byte*, const Ice::Byte*> i outPair.first = &outEncaps[0]; outPair.second = &outEncaps[0] + outEncaps.size(); } - response(ok, outPair); + response(ok, move(outPair)); } #else void diff --git a/cpp/test/Ice/invoke/BlobjectI.h b/cpp/test/Ice/invoke/BlobjectI.h index 5e2d384be37..8ba548e5b14 100644 --- a/cpp/test/Ice/invoke/BlobjectI.h +++ b/cpp/test/Ice/invoke/BlobjectI.h @@ -33,7 +33,8 @@ class BlobjectAsyncI : public Ice::BlobjectAsync public: virtual void ice_invoke_async(std::vector<Ice::Byte>, - std::function<void (bool, const std::vector<Ice::Byte>&)>, + std::function<void (bool, std::vector<Ice::Byte>)>, + std::function<void (std::exception_ptr)>, const Ice::Current&); }; @@ -42,7 +43,8 @@ class BlobjectArrayAsyncI : public Ice::BlobjectArrayAsync public: virtual void ice_invoke_async(std::pair<const Ice::Byte*, const Ice::Byte*>, - std::function<void (bool, const std::pair<const Ice::Byte*, const Ice::Byte*>&)>, + std::function<void (bool, std::pair<const Ice::Byte*, const Ice::Byte*>)>, + std::function<void (std::exception_ptr)>, const Ice::Current&); }; #else diff --git a/cpp/test/Makefile b/cpp/test/Makefile index 019710e9164..c7d629810ff 100644 --- a/cpp/test/Makefile +++ b/cpp/test/Makefile @@ -15,7 +15,8 @@ ifeq ($(CPP11_MAPPING),yes) SUBDIRS = Common \ IceUtil \ Slice \ - Ice + Ice \ + IceDiscovery else SUBDIRS = Common \ diff --git a/cpp/test/Makefile.mak b/cpp/test/Makefile.mak index ace4d3a2953..f4d7534085d 100644 --- a/cpp/test/Makefile.mak +++ b/cpp/test/Makefile.mak @@ -19,7 +19,8 @@ SUBDIRS = Common \ !elseif "$(CPP11_MAPPING)" == "yes" SUBDIRS = IceUtil \ Slice \ - Ice + Ice \ + IceDiscovery !elseif "$(CPP_COMPILER)" == "VC100" SUBDIRS = IceUtil \ Slice \ |