diff options
author | Jose <jose@zeroc.com> | 2015-12-30 18:06:36 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2015-12-30 18:06:36 +0100 |
commit | 95262b044798ae9930a4766afc25372d7ae125fe (patch) | |
tree | a5b2c17438374b9249bd7d06561d3a549465e71e /cpp/src/Ice/Object.cpp | |
parent | C++ lambda cleanup (diff) | |
download | ice-95262b044798ae9930a4766afc25372d7ae125fe.tar.bz2 ice-95262b044798ae9930a4766afc25372d7ae125fe.tar.xz ice-95262b044798ae9930a4766afc25372d7ae125fe.zip |
C++11 ice_invoke_async & Blobject async implementation
Diffstat (limited to 'cpp/src/Ice/Object.cpp')
-rw-r--r-- | cpp/src/Ice/Object.cpp | 84 |
1 files changed, 74 insertions, 10 deletions
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index a4d28141c6e..637fa0977ad 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -403,13 +403,49 @@ Ice::BlobjectArray::__dispatch(Incoming& in, const Current& current) DispatchStatus Ice::BlobjectAsync::__dispatch(Incoming& in, const Current& current) { -#ifdef ICE_CPP11_MAPPING - // TODO - return DispatchAsync; -#else const Byte* inEncaps; Int sz; in.readParamEncaps(inEncaps, sz); +#ifdef ICE_CPP11_MAPPING + auto async = IncomingAsync::create(in); + try + { + ice_invoke_async(vector<Byte>(inEncaps, inEncaps + sz), + [async](bool ok, const vector<Byte>& outEncaps) + { + if(async->__validateResponse(ok)) + { + try + { + if(outEncaps.empty()) + { + async->__writeParamEncaps(0, 0, ok); + } + else + { + async->__writeParamEncaps(&outEncaps[0], static_cast< ::Ice::Int>(outEncaps.size()), ok); + } + } + catch(const LocalException& ex) + { + async->__exception(ex); + return; + } + async->__response(); + } + }, + current); + } + catch(const ::std::exception& ex) + { + async->ice_exception(ex); + } + catch(...) + { + async->ice_exception(); + } +#else + AMD_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Object_ice_invoke(in); try { @@ -423,21 +459,49 @@ Ice::BlobjectAsync::__dispatch(Incoming& in, const Current& current) { cb->ice_exception(); } - return DispatchAsync; #endif + return DispatchAsync; } DispatchStatus Ice::BlobjectArrayAsync::__dispatch(Incoming& in, const Current& current) { -#ifdef ICE_CPP11_MAPPING - // TODO - return DispatchAsync; -#else pair<const Byte*, const Byte*> inEncaps; Int sz; in.readParamEncaps(inEncaps.first, sz); inEncaps.second = inEncaps.first + sz; +#ifdef ICE_CPP11_MAPPING + auto async = IncomingAsync::create(in); + try + { + ice_invoke_async(inEncaps, + [async](bool ok, const pair<const Byte*, const Byte*>& outEncaps) + { + if(async->__validateResponse(ok)) + { + try + { + async->__writeParamEncaps(outEncaps.first, static_cast<Int>(outEncaps.second - outEncaps.first), ok); + } + catch(const LocalException& ex) + { + async->__exception(ex); + return; + } + async->__response(); + } + }, + current); + } + catch(const ::std::exception& ex) + { + async->ice_exception(ex); + } + catch(...) + { + async->ice_exception(); + } +#else AMD_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Object_ice_invoke(in); try { @@ -451,8 +515,8 @@ Ice::BlobjectArrayAsync::__dispatch(Incoming& in, const Current& current) { cb->ice_exception(); } - return DispatchAsync; #endif + return DispatchAsync; } void |