diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Ice/OutgoingAsync.h | 52 | ||||
-rw-r--r-- | cpp/include/Ice/OutgoingAsyncF.h | 4 | ||||
-rw-r--r-- | cpp/include/Ice/Proxy.h | 477 | ||||
-rw-r--r-- | cpp/src/Ice/CollocatedRequestHandler.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectRequestHandler.cpp | 48 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectRequestHandler.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionRequestHandler.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Ice/LoggerAdminI.cpp | 126 | ||||
-rw-r--r-- | cpp/src/Ice/OutgoingAsync.cpp | 135 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 69 | ||||
-rw-r--r-- | cpp/src/Ice/RequestHandler.cpp | 5 | ||||
-rw-r--r-- | cpp/src/Ice/RequestHandler.h | 3 | ||||
-rw-r--r-- | cpp/test/Ice/ami/AllTests.cpp | 140 | ||||
-rw-r--r-- | cpp/test/Ice/ami/Client.cpp | 4 | ||||
-rw-r--r-- | cpp/test/Ice/ami/Collocated.cpp | 4 |
15 files changed, 762 insertions, 319 deletions
diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index b7a14f2dd39..507ead6df62 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -122,7 +122,7 @@ public: virtual void __invokeException(const Exception&); // Required to be public for AsynchronousException void __invokeSent(); // Required to be public for AsynchronousSent - void __attachRemoteObserver(const Ice::ConnectionInfoPtr& c, const Ice::EndpointPtr& endpt, + void __attachRemoteObserver(const Ice::ConnectionInfoPtr& c, const Ice::EndpointPtr& endpt, Ice::Int requestId, Ice::Int sz) { _childObserver.attach(_observer.getRemoteObserver(c, endpt, requestId, sz)); @@ -130,9 +130,9 @@ public: void __attachCollocatedObserver(const Ice::ObjectAdapterPtr& adapter, Ice::Int requestId) { - _childObserver.attach(_observer.getCollocatedObserver(adapter, - requestId, - static_cast<Ice::Int>(_os.b.size() - + _childObserver.attach(_observer.getCollocatedObserver(adapter, + requestId, + static_cast<Ice::Int>(_os.b.size() - IceInternal::headerSize - 4))); } @@ -213,9 +213,9 @@ public: // // Called by the connection when the message is confirmed sent. The connection is locked - // when this is called so this method can call the sent callback. Instead, this method + // when this is called so this method can't call the sent callback. Instead, this method // returns true if there's a sent callback and false otherwise. If true is returned, the - // connection will call the __invokeSentCallback() method bellow (which in turn should + // connection will call the __invokeSentCallback() method bellow (which in turn should // call the sent callback). // virtual bool __sent() = 0; @@ -294,14 +294,16 @@ public: protected: Ice::ObjectPrx _proxy; + RequestHandlerPtr _handler; + int _cnt; private: void handleException(const Ice::Exception&); - RequestHandlerPtr _handler; + Ice::EncodingVersion _encoding; - int _cnt; + bool _sent; Ice::OperationMode _mode; }; @@ -336,7 +338,7 @@ public: } private: - + Ice::ObjectPrx _proxy; }; @@ -373,6 +375,26 @@ private: int _useCount; }; +class ICE_API GetConnectionOutgoingAsync : public OutgoingAsync +{ +public: + + GetConnectionOutgoingAsync(const Ice::ObjectPrx&, const std::string&, const CallbackBasePtr&, + const Ice::LocalObjectPtr&); + + void __invoke(); + + virtual AsyncStatus __send(const Ice::ConnectionIPtr&, bool, bool); + virtual AsyncStatus __invokeCollocated(CollocatedRequestHandler*); + virtual bool __sent(); + virtual void __invokeSent(); + virtual void __finished(const Ice::Exception&); + +private: + + void handleException(const Ice::Exception&); +}; + // // Base class for all callbacks. // @@ -467,7 +489,7 @@ template<typename Callable, typename = void> struct callable_type static const int value = 1; }; -template<class Callable> struct callable_type<Callable, typename ::std::enable_if< ::std::is_class<Callable>::value && +template<class Callable> struct callable_type<Callable, typename ::std::enable_if< ::std::is_class<Callable>::value && !::std::is_bind_expression<Callable>::value>::type> { template<typename T, T> struct TypeCheck; @@ -491,7 +513,7 @@ template<class Callable> struct callable_type<Callable, typename ::std::enable_i enum { value = sizeof(check<Callable>(0)) }; }; -template<> struct callable_type<void(*)(const ::Ice::AsyncResultPtr&)> +template<> struct callable_type<void(*)(const ::Ice::AsyncResultPtr&)> { static const int value = 2; }; @@ -514,11 +536,11 @@ public: template<typename T> Function(T f, typename ::std::enable_if<is_callable<T, S>::value>::type* = 0) : std::function<S>(f) { } - + Function() { } - + Function(::std::nullptr_t) : ::std::function<S>(nullptr) { } @@ -553,7 +575,7 @@ newCallback(T* instance, ICE_API CallbackPtr newCallback(const ::IceInternal::Function<void (const AsyncResultPtr&)>&, - const ::IceInternal::Function<void (const AsyncResultPtr&)>& = + const ::IceInternal::Function<void (const AsyncResultPtr&)>& = ::IceInternal::Function<void (const AsyncResultPtr&)>()); #endif @@ -565,7 +587,7 @@ newCallback(const ::IceInternal::Function<void (const AsyncResultPtr&)>&, // Interfaces for the deprecated AMI mapping. // -class ICE_API AMISentCallback +class ICE_API AMISentCallback { public: diff --git a/cpp/include/Ice/OutgoingAsyncF.h b/cpp/include/Ice/OutgoingAsyncF.h index 3e709ccc366..9675fa6c468 100644 --- a/cpp/include/Ice/OutgoingAsyncF.h +++ b/cpp/include/Ice/OutgoingAsyncF.h @@ -50,6 +50,10 @@ class CommunicatorBatchOutgoingAsync; ICE_API IceUtil::Shared* upCast(CommunicatorBatchOutgoingAsync*); typedef IceInternal::Handle<CommunicatorBatchOutgoingAsync> CommunicatorBatchOutgoingAsyncPtr; +class GetConnectionOutgoingAsync; +ICE_API IceUtil::Shared* upCast(GetConnectionOutgoingAsync*); +typedef IceInternal::Handle<GetConnectionOutgoingAsync> GetConnectionOutgoingAsyncPtr; + } #endif diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index 8ef8469537b..8a17329b44b 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -82,6 +82,9 @@ typedef ::IceUtil::Handle< Callback_Object_ice_invoke_Base> Callback_Object_ice_ class Callback_Object_ice_flushBatchRequests_Base : virtual public ::IceInternal::CallbackBase { }; typedef ::IceUtil::Handle< Callback_Object_ice_flushBatchRequests_Base> Callback_Object_ice_flushBatchRequestsPtr; +class Callback_Object_ice_getConnection_Base : virtual public ::IceInternal::CallbackBase { }; +typedef ::IceUtil::Handle< Callback_Object_ice_getConnection_Base> Callback_Object_ice_getConnectionPtr; + // // Deprecated AMI callbacks // @@ -101,7 +104,7 @@ public: { ice_exception(ex); } - + void __sent(bool sentSynchronously) { AMICallbackBase::__sent(sentSynchronously); @@ -124,7 +127,7 @@ public: { ice_exception(ex); } - + void __sent(bool sentSynchronously) { AMICallbackBase::__sent(sentSynchronously); @@ -140,7 +143,7 @@ public: { ice_exception(ex); } - + void __sent(bool sentSynchronously) { AMICallbackBase::__sent(sentSynchronously); @@ -164,7 +167,7 @@ public: virtual CallbackBasePtr verify(const ::Ice::LocalObjectPtr&); virtual void sent(const ::Ice::AsyncResultPtr&) const; - + virtual bool hasSentCallback() const; protected: @@ -178,16 +181,16 @@ protected: class ICE_API Cpp11FnOnewayCallbackNC : public Cpp11FnCallbackNC { public: - + Cpp11FnOnewayCallbackNC(const ::std::function<void ()>&, const ::std::function<void (const ::Ice::Exception&)>&, const ::std::function<void (bool)>&); virtual void completed(const ::Ice::AsyncResultPtr&) const; - + private: - + ::std::function<void ()> _cb; }; @@ -200,7 +203,7 @@ namespace IceProxy { namespace Ice class ICE_API Object : public ::IceUtil::Shared { public: - + bool operator==(const Object&) const; bool operator!=(const Object&) const; bool operator<(const Object&) const; @@ -217,42 +220,42 @@ public: { return ice_isA(typeId, &context); } - + #ifdef ICE_CPP11 ::Ice::AsyncResultPtr - begin_ice_isA(const ::std::string& typeId, - const ::Ice::Context& ctx, - const ::IceInternal::Function<void (bool)>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + begin_ice_isA(const ::std::string& typeId, + const ::Ice::Context& ctx, + const ::IceInternal::Function<void (bool)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_isA(typeId, &ctx, response, exception, sent); } - + ::Ice::AsyncResultPtr - begin_ice_isA(const ::std::string& typeId, - const ::IceInternal::Function<void (bool)>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + begin_ice_isA(const ::std::string& typeId, + const ::IceInternal::Function<void (bool)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_isA(typeId, 0, response, exception, sent); } - + ::Ice::AsyncResultPtr - begin_ice_isA(const ::std::string& typeId, + begin_ice_isA(const ::std::string& typeId, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { return begin_ice_isA(typeId, 0, ::Ice::newCallback(completed, sent), 0); } - + ::Ice::AsyncResultPtr - begin_ice_isA(const ::std::string& typeId, - const ::Ice::Context& ctx, - const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + begin_ice_isA(const ::std::string& typeId, + const ::Ice::Context& ctx, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { @@ -301,7 +304,7 @@ public: } bool end_ice_isA(const ::Ice::AsyncResultPtr&); - + void ice_ping() { ice_ping(0); @@ -310,38 +313,38 @@ public: { ice_ping(&context); } - + #ifdef ICE_CPP11 ::Ice::AsyncResultPtr - begin_ice_ping(const ::IceInternal::Function<void ()>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + begin_ice_ping(const ::IceInternal::Function<void ()>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_ping(0, response, exception, sent); } - + ::Ice::AsyncResultPtr begin_ice_ping(const ::Ice::Context& ctx, - const ::IceInternal::Function<void ()>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + const ::IceInternal::Function<void ()>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_ping(&ctx, response, exception, sent); } - + ::Ice::AsyncResultPtr - begin_ice_ping(const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + begin_ice_ping(const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { return begin_ice_ping(0, ::Ice::newCallback(completed, sent), 0); } - + ::Ice::AsyncResultPtr - begin_ice_ping(const ::Ice::Context& ctx, - const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + begin_ice_ping(const ::Ice::Context& ctx, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { @@ -394,39 +397,39 @@ public: { return ice_ids(&context); } - + #ifdef ICE_CPP11 ::Ice::AsyncResultPtr - begin_ice_ids(const ::IceInternal::Function<void (const ::std::vector< ::std::string>&)>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + begin_ice_ids(const ::IceInternal::Function<void (const ::std::vector< ::std::string>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_ids(0, response, exception, sent); } - + ::Ice::AsyncResultPtr begin_ice_ids(const ::Ice::Context& ctx, const ::IceInternal::Function<void (const ::std::vector< ::std::string>&)>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_ids(&ctx, response, exception, sent); } - + ::Ice::AsyncResultPtr - begin_ice_ids(const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, - const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + begin_ice_ids(const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { return begin_ice_ids(0, ::Ice::newCallback(completed, sent), 0); } - + ::Ice::AsyncResultPtr - begin_ice_ids(const ::Ice::Context& ctx, + begin_ice_ids(const ::Ice::Context& ctx, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, - const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { return begin_ice_ids(&ctx, ::Ice::newCallback(completed, sent), 0); @@ -470,7 +473,7 @@ public: } ::std::vector< ::std::string> end_ice_ids(const ::Ice::AsyncResultPtr&); - + ::std::string ice_id() { return ice_id(0); @@ -479,27 +482,27 @@ public: { return ice_id(&context); } - + #ifdef ICE_CPP11 ::Ice::AsyncResultPtr - begin_ice_id(const ::IceInternal::Function<void (const ::std::string&)>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + begin_ice_id(const ::IceInternal::Function<void (const ::std::string&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_id(0, response, exception, sent); } - + ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Context& ctx, - const ::IceInternal::Function<void (const ::std::string&)>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + const ::IceInternal::Function<void (const ::std::string&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_id(&ctx, response, exception, sent); } - + ::Ice::AsyncResultPtr begin_ice_id(const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = @@ -507,11 +510,11 @@ public: { return begin_ice_id(0, ::Ice::newCallback(completed, sent), 0); } - + ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Context& ctx, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, - const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { return begin_ice_id(&ctx, ::Ice::newCallback(completed, sent), 0); @@ -560,20 +563,20 @@ public: static const ::std::string& ice_staticId() { return ::Ice::Object::ice_staticId(); - } + } // Returns true if ok, false if user exception. - bool ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + bool ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams, ::std::vector< ::Ice::Byte>& outParams) { return ice_invoke(operation, mode, inParams, outParams, 0); } - bool ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + bool ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams, ::std::vector< ::Ice::Byte>& outParams, const ::Ice::Context& context) @@ -588,50 +591,50 @@ public: #ifdef ICE_CPP11 ::Ice::AsyncResultPtr begin_ice_invoke( - const ::std::string& operation, - ::Ice::OperationMode mode, + const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams, - const ::IceInternal::Function<void (bool, const ::std::vector< ::Ice::Byte>&)>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + const ::IceInternal::Function<void (bool, const ::std::vector< ::Ice::Byte>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_invoke(operation, mode, inParams, 0, response, exception, sent); } - + ::Ice::AsyncResultPtr begin_ice_invoke( - const ::std::string& operation, - ::Ice::OperationMode mode, + const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams, const ::Ice::Context& ctx, const ::IceInternal::Function<void (bool, const ::std::vector< ::Ice::Byte>&)>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_invoke(operation, mode, inParams, &ctx, response, exception, sent); } - + ::Ice::AsyncResultPtr begin_ice_invoke( const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, const ::IceInternal::Function<void (bool, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&)>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return __begin_ice_invoke(operation, mode, inParams, 0, response, exception, sent); } - + ::Ice::AsyncResultPtr begin_ice_invoke( const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, const ::Ice::Context& ctx, const ::IceInternal::Function<void (bool, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&)>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { @@ -639,23 +642,23 @@ public: } #endif - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams) { return begin_ice_invoke(operation, mode, inParams, 0, ::IceInternal::__dummyCallback, 0); } - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams, const ::Ice::Context& __ctx) { return begin_ice_invoke(operation, mode, inParams, &__ctx, ::IceInternal::__dummyCallback, 0); } - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) @@ -663,8 +666,8 @@ public: return begin_ice_invoke(operation, mode, inParams, 0, __del, __cookie); } - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams, const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, @@ -673,8 +676,8 @@ public: return begin_ice_invoke(operation, mode, inParams, &__ctx, __del, __cookie); } - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams, const ::Ice::Callback_Object_ice_invokePtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) @@ -682,8 +685,8 @@ public: return begin_ice_invoke(operation, mode, inParams, 0, __del, __cookie); } - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams, const ::Ice::Context& __ctx, const ::Ice::Callback_Object_ice_invokePtr& __del, @@ -694,15 +697,15 @@ public: bool end_ice_invoke(::std::vector< ::Ice::Byte>&, const ::Ice::AsyncResultPtr&); - bool ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, - const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, + bool ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, + const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, ::std::vector< ::Ice::Byte>& outParams) { return ice_invoke(operation, mode, inParams, outParams, 0); } - bool ice_invoke(const ::std::string& operation, + bool ice_invoke(const ::std::string& operation, ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, ::std::vector< ::Ice::Byte>& outParams, @@ -713,18 +716,18 @@ public: bool ice_invoke_async(const ::Ice::AMI_Array_Object_ice_invokePtr&, const ::std::string&, ::Ice::OperationMode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&); - bool ice_invoke_async(const ::Ice::AMI_Array_Object_ice_invokePtr&, const ::std::string&, ::Ice::OperationMode, + bool ice_invoke_async(const ::Ice::AMI_Array_Object_ice_invokePtr&, const ::std::string&, ::Ice::OperationMode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&, const ::Ice::Context&); - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams) { return begin_ice_invoke(operation, mode, inParams, 0, ::IceInternal::__dummyCallback, 0); } - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, const ::Ice::Context& __ctx, const ::Ice::LocalObjectPtr& __cookie = 0) @@ -732,8 +735,8 @@ public: return begin_ice_invoke(operation, mode, inParams, &__ctx, ::IceInternal::__dummyCallback, __cookie); } - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) @@ -741,8 +744,8 @@ public: return begin_ice_invoke(operation, mode, inParams, 0, __del, __cookie); } - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, @@ -751,8 +754,8 @@ public: return begin_ice_invoke(operation, mode, inParams, &__ctx, __del, __cookie); } - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, const ::Ice::Callback_Object_ice_invokePtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) @@ -760,8 +763,8 @@ public: return begin_ice_invoke(operation, mode, inParams, 0, __del, __cookie); } - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, const ::Ice::Context& __ctx, const ::Ice::Callback_Object_ice_invokePtr& __del, @@ -835,14 +838,47 @@ public: ::std::string ice_getConnectionId() const; ::Ice::ConnectionPtr ice_getConnection(); + +#ifdef ICE_CPP11 + ::Ice::AsyncResultPtr begin_ice_getConnection( + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed) + { + return begin_ice_getConnectionInternal(::Ice::newCallback(completed, 0), 0); + } + + ::Ice::AsyncResultPtr begin_ice_getConnection( + const ::IceInternal::Function<void (const ::Ice::ConnectionPtr&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>()); +#endif + + ::Ice::AsyncResultPtr begin_ice_getConnection() + { + return begin_ice_getConnectionInternal(::IceInternal::__dummyCallback, 0); + } + + ::Ice::AsyncResultPtr begin_ice_getConnection(const ::Ice::CallbackPtr& __del, + const ::Ice::LocalObjectPtr& __cookie = 0) + { + return begin_ice_getConnectionInternal(__del, __cookie); + } + + ::Ice::AsyncResultPtr begin_ice_getConnection(const ::Ice::Callback_Object_ice_getConnectionPtr& __del, + const ::Ice::LocalObjectPtr& __cookie = 0) + { + return begin_ice_getConnectionInternal(__del, __cookie); + } + + ::Ice::ConnectionPtr end_ice_getConnection(const ::Ice::AsyncResultPtr&); + ::Ice::ConnectionPtr ice_getCachedConnection() const; void ice_flushBatchRequests(); bool ice_flushBatchRequests_async(const ::Ice::AMI_Object_ice_flushBatchRequestsPtr&); - + #ifdef ICE_CPP11 ::Ice::AsyncResultPtr begin_ice_flushBatchRequests( - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception, const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { return begin_ice_flushBatchRequestsInternal( @@ -875,7 +911,7 @@ public: void __copyFrom(const ::Ice::ObjectPrx&); - int __handleException(const ::Ice::Exception&, const ::IceInternal::RequestHandlerPtr&, ::Ice::OperationMode, + int __handleException(const ::Ice::Exception&, const ::IceInternal::RequestHandlerPtr&, ::Ice::OperationMode, bool, int&); void __checkTwowayOnly(const ::std::string&) const; @@ -890,7 +926,7 @@ public: protected: virtual Object* __newInstance() const; - + private: ::IceInternal::RequestHandlerPtr createRequestHandler(); @@ -903,10 +939,10 @@ private: #ifdef ICE_CPP11 ::Ice::AsyncResultPtr __begin_ice_isA( - const ::std::string&, + const ::std::string&, const ::Ice::Context*, - const ::IceInternal::Function<void (bool)>&, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& = + const ::IceInternal::Function<void (bool)>&, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& = ::IceInternal::Function<void (bool)>()); #endif @@ -920,8 +956,8 @@ private: #ifdef ICE_CPP11 ::Ice::AsyncResultPtr __begin_ice_ping( const ::Ice::Context* ctx, - const ::IceInternal::Function<void ()>& response, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + const ::IceInternal::Function<void ()>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { @@ -938,7 +974,7 @@ private: ::Ice::AsyncResultPtr __begin_ice_ids( const ::Ice::Context*, const ::IceInternal::Function<void (const ::std::vector< ::std::string>&)>&, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& = + const ::IceInternal::Function<void (const ::Ice::Exception&)>& = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& = ::IceInternal::Function<void (bool)>()); @@ -951,21 +987,21 @@ private: #ifdef ICE_CPP11 ::Ice::AsyncResultPtr __begin_ice_id( const ::Ice::Context*, - const ::IceInternal::Function<void (const ::std::string&)>&, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& = + const ::IceInternal::Function<void (const ::std::string&)>&, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& = ::IceInternal::Function<void (const ::Ice::Exception&)>(), - const ::IceInternal::Function<void (bool)>& sent = + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()); #endif - bool ice_invoke(const ::std::string&, - ::Ice::OperationMode, + bool ice_invoke(const ::std::string&, + ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&, ::std::vector< ::Ice::Byte>&, const ::Ice::Context*); - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string&, - ::Ice::OperationMode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string&, + ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&, const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, @@ -973,42 +1009,45 @@ private: #ifdef ICE_CPP11 ::Ice::AsyncResultPtr __begin_ice_invoke( - const ::std::string&, - ::Ice::OperationMode, + const ::std::string&, + ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&, const ::Ice::Context*, const ::IceInternal::Function<void (bool, const ::std::vector< ::Ice::Byte>&)>&, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& = + const ::IceInternal::Function<void (const ::Ice::Exception&)>& = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& = ::IceInternal::Function<void (bool)>()); - + #endif - bool ice_invoke(const ::std::string&, + bool ice_invoke(const ::std::string&, ::Ice::OperationMode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&, ::std::vector< ::Ice::Byte>&, const ::Ice::Context*); - ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string&, - ::Ice::OperationMode, + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string&, + ::Ice::OperationMode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&, const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr&); - + #ifdef ICE_CPP11 ::Ice::AsyncResultPtr __begin_ice_invoke( const ::std::string&, - ::Ice::OperationMode, + ::Ice::OperationMode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&, const ::Ice::Context*, const ::IceInternal::Function<void (bool, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&)>&, - const ::IceInternal::Function<void (const ::Ice::Exception&)>& = + const ::IceInternal::Function<void (const ::Ice::Exception&)>& = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& = ::IceInternal::Function<void (bool)>()); #endif + ::Ice::AsyncResultPtr begin_ice_getConnectionInternal(const ::IceInternal::CallbackBasePtr&, + const ::Ice::LocalObjectPtr&); + ::Ice::AsyncResultPtr begin_ice_flushBatchRequestsInternal(const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr&); @@ -1085,7 +1124,7 @@ inline bool operator==(const ProxyHandle<T>& lhs, const ProxyHandle<U>& rhs) else { return !l && !r; - } + } } template<typename T, typename U> @@ -1131,7 +1170,7 @@ inline bool operator>=(const ProxyHandle<T>& lhs, const ProxyHandle<U>& rhs) // // checkedCast and uncheckedCast functions without facet: // -template<typename P> P +template<typename P> P checkedCastImpl(const ::Ice::ObjectPrx& b, const ::Ice::Context* context) { P d = 0; @@ -1140,7 +1179,7 @@ checkedCastImpl(const ::Ice::ObjectPrx& b, const ::Ice::Context* context) typedef typename P::element_type T; d = dynamic_cast<T*>(b.get()); - if(!d && (context == 0 ? + if(!d && (context == 0 ? b->ice_isA(T::ice_staticId()) : b->ice_isA(T::ice_staticId(), *context))) { @@ -1151,7 +1190,7 @@ checkedCastImpl(const ::Ice::ObjectPrx& b, const ::Ice::Context* context) return d; } -template<typename P> P +template<typename P> P uncheckedCastImpl(const ::Ice::ObjectPrx& b) { P d = 0; @@ -1169,7 +1208,7 @@ uncheckedCastImpl(const ::Ice::ObjectPrx& b) return d; } -// +// // checkedCast and uncheckedCast with facet: // @@ -1184,13 +1223,13 @@ ICE_API ::Ice::ObjectPrx checkedCastImpl(const ::Ice::ObjectPrx&, const std::str // We have to use inline functions for broken compilers such as VC7. // -template<> inline ::Ice::ObjectPrx +template<> inline ::Ice::ObjectPrx checkedCastImpl< ::Ice::ObjectPrx>(const ::Ice::ObjectPrx& b, const std::string& f, const ::Ice::Context* context) { return checkedCastImpl(b, f, "::Ice::Object", context); } -template<> inline ::Ice::ObjectPrx +template<> inline ::Ice::ObjectPrx uncheckedCastImpl< ::Ice::ObjectPrx>(const ::Ice::ObjectPrx& b, const std::string& f) { ::Ice::ObjectPrx d = 0; @@ -1201,7 +1240,7 @@ uncheckedCastImpl< ::Ice::ObjectPrx>(const ::Ice::ObjectPrx& b, const std::strin return d; } -template<typename P> P +template<typename P> P checkedCastImpl(const ::Ice::ObjectPrx& b, const std::string& f, const ::Ice::Context* context) { P d = 0; @@ -1217,7 +1256,7 @@ checkedCastImpl(const ::Ice::ObjectPrx& b, const std::string& f, const ::Ice::Co return d; } -template<typename P> P +template<typename P> P uncheckedCastImpl(const ::Ice::ObjectPrx& b, const std::string& f) { P d = 0; @@ -1235,9 +1274,9 @@ uncheckedCastImpl(const ::Ice::ObjectPrx& b, const std::string& f) // // checkedCast and uncheckedCast functions provided in the global namespace -// +// -template<typename P, typename Y> inline P +template<typename P, typename Y> inline P checkedCast(const ::IceInternal::ProxyHandle<Y>& b) { Y* tag = 0; @@ -1245,7 +1284,7 @@ checkedCast(const ::IceInternal::ProxyHandle<Y>& b) return ::IceInternal::checkedCastHelper<typename P::element_type>(b, tag, ctx); } -template<typename P, typename Y> inline P +template<typename P, typename Y> inline P checkedCast(const ::IceInternal::ProxyHandle<Y>& b, const ::Ice::Context& context) { Y* tag = 0; @@ -1259,20 +1298,20 @@ uncheckedCast(const ::IceInternal::ProxyHandle<Y>& b) return ::IceInternal::uncheckedCastHelper<typename P::element_type>(b, tag); } -template<typename P> inline P +template<typename P> inline P checkedCast(const ::Ice::ObjectPrx& b, const std::string& f) { Ice::Context* ctx = 0; return ::IceInternal::checkedCastImpl<P>(b, f, ctx); } -template<typename P> inline P +template<typename P> inline P checkedCast(const ::Ice::ObjectPrx& b, const std::string& f, const ::Ice::Context& context) { return ::IceInternal::checkedCastImpl<P>(b, f, &context); } -template<typename P> inline P +template<typename P> inline P uncheckedCast(const ::Ice::ObjectPrx& b, const std::string& f) { return ::IceInternal::uncheckedCastImpl<P>(b, f); @@ -1448,7 +1487,7 @@ public: typedef void (T::*Sent)(bool); typedef void (T::*Response)(); - OnewayCallbackNC(const TPtr& instance, Response cb, Exception excb, Sent sentcb) : + OnewayCallbackNC(const TPtr& instance, Response cb, Exception excb, Sent sentcb) : CallbackNC<T>(instance, excb, sentcb), _response(cb) { CallbackBase::checkCallback(instance, cb != 0 || excb != 0); @@ -1487,7 +1526,7 @@ public: typedef void (T::*Sent)(bool, const CT&); typedef void (T::*Response)(const CT&); - OnewayCallback(const TPtr& instance, Response cb, Exception excb, Sent sentcb) : + OnewayCallback(const TPtr& instance, Response cb, Exception excb, Sent sentcb) : Callback<T, CT>(instance, excb, sentcb), _response(cb) { CallbackBase::checkCallback(instance, cb != 0 || excb != 0); @@ -1511,13 +1550,13 @@ public: } private: - + Response _response; }; } -namespace Ice +namespace Ice { template<class T> @@ -1652,8 +1691,8 @@ public: virtual void completed(const ::Ice::AsyncResultPtr& __result) const { ::std::vector< ::std::string> __ret; - try - { + try + { __ret = __result->getProxy()->end_ice_ids(__result); } catch(const ::Ice::Exception& ex) @@ -1691,8 +1730,8 @@ public: virtual void completed(const ::Ice::AsyncResultPtr& __result) const { ::std::vector< ::std::string> __ret; - try - { + try + { __ret = __result->getProxy()->end_ice_ids(__result); } catch(const ::Ice::Exception& ex) @@ -1702,7 +1741,7 @@ public: } if(_response) { - (::IceInternal::Callback<T, CT>::_callback.get()->*_response)(__ret, + (::IceInternal::Callback<T, CT>::_callback.get()->*_response)(__ret, CT::dynamicCast(__result->getCookie())); } } @@ -1893,8 +1932,8 @@ public: ::IceInternal::Callback<T, CT>::exception(__result, ex); return; } - (::IceInternal::Callback<T, CT>::_callback.get()->*_response)(__ok, - outParams, + (::IceInternal::Callback<T, CT>::_callback.get()->*_response)(__ok, + outParams, CT::dynamicCast(__result->getCookie())); } else @@ -1913,7 +1952,7 @@ public: if(_responseArray) { (::IceInternal::Callback<T, CT>::_callback.get()->*_responseArray)(__ok, - outParams, + outParams, CT::dynamicCast( __result->getCookie())); } @@ -1927,7 +1966,90 @@ private: }; template<class T> -class CallbackNC_Object_ice_flushBatchRequests : public Callback_Object_ice_flushBatchRequests_Base, public ::IceInternal::OnewayCallbackNC<T> +class CallbackNC_Object_ice_getConnection : public Callback_Object_ice_getConnection_Base, + public ::IceInternal::CallbackNC<T> +{ +public: + + typedef IceUtil::Handle<T> TPtr; + + typedef void (T::*Response)(const ::Ice::ConnectionPtr&); + typedef void (T::*Exception)(const ::Ice::Exception&); + typedef void (T::*Sent)(bool); + + CallbackNC_Object_ice_getConnection(const TPtr& instance, Response cb, Exception excb, Sent sentcb) : + ::IceInternal::CallbackNC<T>(instance, excb, sentcb), _response(cb) + { + } + + + virtual void completed(const ::Ice::AsyncResultPtr& __result) const + { + ::Ice::ConnectionPtr __ret; + try + { + __ret = __result->getProxy()->end_ice_getConnection(__result); + } + catch(const ::Ice::Exception& ex) + { + ::IceInternal::CallbackNC<T>::exception(__result, ex); + return; + } + if(_response) + { + (::IceInternal::CallbackNC<T>::_callback.get()->*_response)(__ret); + } + } + +private: + + Response _response; +}; + +template<class T, typename CT> +class Callback_Object_ice_getConnection : public Callback_Object_ice_getConnection_Base, + public ::IceInternal::Callback<T, CT> +{ +public: + + typedef IceUtil::Handle<T> TPtr; + + typedef void (T::*Response)(const ::Ice::ConnectionPtr&, const CT&); + typedef void (T::*Exception)(const ::Ice::Exception&, const CT&); + typedef void (T::*Sent)(bool, const CT&); + + Callback_Object_ice_getConnection(const TPtr& instance, Response cb, Exception excb, Sent sentcb) : + ::IceInternal::Callback<T, CT>(instance, excb, sentcb), _response(cb) + { + } + + virtual void completed(const ::Ice::AsyncResultPtr& __result) const + { + ::Ice::ConnectionPtr __ret; + try + { + __ret = __result->getProxy()->end_ice_getConnection(__result); + } + catch(const ::Ice::Exception& ex) + { + ::IceInternal::Callback<T, CT>::exception(__result, ex); + return; + } + if(_response) + { + (::IceInternal::Callback<T, CT>::_callback.get()->*_response)(__ret, + CT::dynamicCast(__result->getCookie())); + } + } + +private: + + Response _response; +}; + +template<class T> +class CallbackNC_Object_ice_flushBatchRequests : public Callback_Object_ice_flushBatchRequests_Base, + public ::IceInternal::OnewayCallbackNC<T> { public: @@ -1943,7 +2065,8 @@ public: }; template<class T, typename CT> -class Callback_Object_ice_flushBatchRequests : public Callback_Object_ice_flushBatchRequests_Base, public ::IceInternal::OnewayCallback<T, CT> +class Callback_Object_ice_flushBatchRequests : public Callback_Object_ice_flushBatchRequests_Base, + public ::IceInternal::OnewayCallback<T, CT> { public: @@ -2259,7 +2382,7 @@ newCallback_Object_ice_invoke(const IceUtil::Handle<T>& instance, template<class T, typename CT> Callback_Object_ice_invokePtr newCallback_Object_ice_invoke(const IceUtil::Handle<T>& instance, - void (T::*cb)(bool, const std::pair<const Byte*, const Byte*>&, + void (T::*cb)(bool, const std::pair<const Byte*, const Byte*>&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0) @@ -2337,6 +2460,38 @@ newCallback_Object_ice_invoke(T* instance, instance, static_cast<void (T::*)(bool, const std::vector<Ice::Byte>&, const CT&)>(0), excb, sentcb); } +template<class T> Callback_Object_ice_getConnectionPtr +newCallback_Object_ice_getConnection(const IceUtil::Handle<T>& instance, + void (T::*cb)(const ::Ice::ConnectionPtr&), + void (T::*excb)(const ::Ice::Exception&)) +{ + return new CallbackNC_Object_ice_getConnection<T>(instance, cb, excb, 0); +} + +template<class T, typename CT> Callback_Object_ice_getConnectionPtr +newCallback_Object_ice_getConnection(const IceUtil::Handle<T>& instance, + void (T::*cb)(const ::Ice::ConnectionPtr&, const CT&), + void (T::*excb)(const ::Ice::Exception&, const CT&)) +{ + return new Callback_Object_ice_getConnection<T, CT>(instance, cb, excb, 0); +} + +template<class T> Callback_Object_ice_getConnectionPtr +newCallback_Object_ice_getConnection(T* instance, + void (T::*cb)(const ::Ice::ConnectionPtr&), + void (T::*excb)(const ::Ice::Exception&)) +{ + return new CallbackNC_Object_ice_getConnection<T>(instance, cb, excb, 0); +} + +template<class T, typename CT> Callback_Object_ice_getConnectionPtr +newCallback_Object_ice_getConnection(T* instance, + void (T::*cb)(const ::Ice::ConnectionPtr&, const CT&), + void (T::*excb)(const ::Ice::Exception&, const CT&)) +{ + return new Callback_Object_ice_getConnection<T, CT>(instance, cb, excb, 0); +} + template<class T> Callback_Object_ice_flushBatchRequestsPtr newCallback_Object_ice_flushBatchRequests(const IceUtil::Handle<T>& instance, void (T::*excb)(const ::Ice::Exception&), diff --git a/cpp/src/Ice/CollocatedRequestHandler.h b/cpp/src/Ice/CollocatedRequestHandler.h index 7b80a2a036a..36462f80feb 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.h +++ b/cpp/src/Ice/CollocatedRequestHandler.h @@ -63,7 +63,7 @@ public: virtual Ice::ConnectionIPtr getConnection(); virtual Ice::ConnectionIPtr waitForConnection(); - + void invokeRequest(Outgoing*); AsyncStatus invokeAsyncRequest(OutgoingAsync*); void invokeBatchRequests(BatchOutgoing*); @@ -77,7 +77,7 @@ public: private: void handleException(Ice::Int, const Ice::Exception&); - + const Ice::ObjectAdapterIPtr _adapter; const bool _dispatcher; const Ice::LoggerPtr _logger; diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp index 10f756be30c..874858e1c7e 100644 --- a/cpp/src/Ice/ConnectRequestHandler.cpp +++ b/cpp/src/Ice/ConnectRequestHandler.cpp @@ -28,27 +28,27 @@ namespace class FlushRequestsWithException : public DispatchWorkItem { public: - + FlushRequestsWithException(const Ice::ConnectionPtr& connection, const ConnectRequestHandlerPtr& handler) : DispatchWorkItem(connection), _handler(handler) { } - + virtual void run() { _handler->flushRequestsWithException(); } - + private: - + const ConnectRequestHandlerPtr _handler; }; class FlushSentRequests : public DispatchWorkItem { public: - + FlushSentRequests(const Ice::ConnectionPtr& connection, const vector<OutgoingAsyncMessageCallbackPtr>& callbacks) : DispatchWorkItem(connection), _callbacks(callbacks) { @@ -115,7 +115,7 @@ ConnectRequestHandler::prepareBatchRequest(BasicStream* os) { wait(); } - + try { if(!initialized()) @@ -146,7 +146,7 @@ ConnectRequestHandler::finishBatchRequest(BasicStream* os) _batchStream.swap(*os); - if(!_batchAutoFlush && + if(!_batchAutoFlush && _batchStream.b.size() + _batchRequestsSize > _reference->getInstance()->messageSizeMax()) { Ex::throwMemoryLimitException(__FILE__, __LINE__, _batchStream.b.size() + _batchRequestsSize, @@ -259,7 +259,7 @@ ConnectRequestHandler::requestTimedOut(OutgoingMessageCallback* out) _connection->requestTimedOut(out); } -void +void ConnectRequestHandler::asyncRequestTimedOut(const OutgoingAsyncMessageCallbackPtr& outAsync) { { @@ -298,7 +298,7 @@ ConnectRequestHandler::getConnection() else { return _connection; - } + } } Ice::ConnectionIPtr @@ -309,7 +309,7 @@ ConnectRequestHandler::waitForConnection() { throw RetryException(*_exception.get()); } - + // // Wait for the connection establishment to complete or fail. // @@ -326,7 +326,7 @@ ConnectRequestHandler::waitForConnection() else { return _connection; - } + } } void @@ -340,7 +340,7 @@ ConnectRequestHandler::setConnection(const Ice::ConnectionIPtr& connection, bool _connection = connection; _compress = compress; } - + // // If this proxy is for a non-local object, and we are using a router, then // add this proxy to the router info object. @@ -369,7 +369,7 @@ ConnectRequestHandler::setException(const Ice::LocalException& ex) // // If some requests were queued, we notify them of the failure. This is done from a thread - // from the client thread pool since this will result in ice_exception callbacks to be + // from the client thread pool since this will result in ice_exception callbacks to be // called. // if(!_requests.empty()) @@ -384,7 +384,7 @@ void ConnectRequestHandler::addedProxy() { // - // The proxy was added to the router info, we're now ready to send the + // The proxy was added to the router info, we're now ready to send the // queued requests. // flushRequests(); @@ -406,7 +406,7 @@ ConnectRequestHandler::initialized() { wait(); } - + if(_exception.get()) { _exception->ice_throw(); @@ -425,17 +425,17 @@ ConnectRequestHandler::flushRequests() { Lock sync(*this); assert(_connection && !_initialized); - + while(_batchRequestInProgress) { wait(); } - + // // We set the _flushing flag to true to prevent any additional queuing. Callers // might block for a little while as the queued requests are being sent but this // shouldn't be an issue as the request sends are non-blocking. - // + // _flushing = true; } @@ -486,7 +486,7 @@ ConnectRequestHandler::flushRequests() // RetryException. We handle the exception like it // was an exception that occured while sending the // request. - // + // Lock sync(*this); assert(!_exception.get() && !_requests.empty()); _exception.reset(ex.get()->ice_clone()); @@ -504,11 +504,11 @@ ConnectRequestHandler::flushRequests() { _reference->getInstance()->clientThreadPool()->dispatch(new FlushSentRequests(_connection, sentCallbacks)); } - + // // We've finished sending the queued requests and the request handler now sends - // the requests over the connection directly. It's time to substitute the - // request handler of the proxy with the more efficient connection request + // the requests over the connection directly. It's time to substitute the + // request handler of the proxy with the more efficient connection request // handler which does not have any synchronization. This also breaks the cyclic // reference count with the proxy. // @@ -538,11 +538,11 @@ ConnectRequestHandler::flushRequestsWithException() for(deque<Request>::const_iterator p = _requests.begin(); p != _requests.end(); ++p) { if(p->out) - { + { p->out->finished(*_exception.get()); } else if(p->outAsync) - { + { p->outAsync->__finished(*_exception.get()); } else diff --git a/cpp/src/Ice/ConnectRequestHandler.h b/cpp/src/Ice/ConnectRequestHandler.h index a95f62f8717..ea86da211ff 100644 --- a/cpp/src/Ice/ConnectRequestHandler.h +++ b/cpp/src/Ice/ConnectRequestHandler.h @@ -25,7 +25,7 @@ namespace IceInternal { -class ConnectRequestHandler : public RequestHandler, +class ConnectRequestHandler : public RequestHandler, public Reference::GetConnectionCallback, public RouterInfo::AddProxyCallback, public IceUtil::Monitor<IceUtil::Mutex> diff --git a/cpp/src/Ice/ConnectionRequestHandler.cpp b/cpp/src/Ice/ConnectionRequestHandler.cpp index fba1ee9dc34..4d9d746675d 100644 --- a/cpp/src/Ice/ConnectionRequestHandler.cpp +++ b/cpp/src/Ice/ConnectionRequestHandler.cpp @@ -29,8 +29,8 @@ ConnectionRequestHandler::ConnectionRequestHandler(const ReferencePtr& reference } } -ConnectionRequestHandler::ConnectionRequestHandler(const ReferencePtr& reference, - const Ice::ConnectionIPtr& connection, +ConnectionRequestHandler::ConnectionRequestHandler(const ReferencePtr& reference, + const Ice::ConnectionIPtr& connection, bool compress) : RequestHandler(reference), _connection(connection), @@ -68,13 +68,13 @@ ConnectionRequestHandler::sendAsyncRequest(const OutgoingAsyncMessageCallbackPtr return out->__send(_connection, _compress, _response); } -void +void ConnectionRequestHandler::requestTimedOut(OutgoingMessageCallback* out) { _connection->requestTimedOut(out); } -void +void ConnectionRequestHandler::asyncRequestTimedOut(const OutgoingAsyncMessageCallbackPtr& outAsync) { _connection->asyncRequestTimedOut(outAsync); diff --git a/cpp/src/Ice/LoggerAdminI.cpp b/cpp/src/Ice/LoggerAdminI.cpp index a673a695f6c..4ce2cd073e2 100644 --- a/cpp/src/Ice/LoggerAdminI.cpp +++ b/cpp/src/Ice/LoggerAdminI.cpp @@ -35,15 +35,15 @@ public: virtual void attachRemoteLogger(const RemoteLoggerPrx&, const LogMessageTypeSeq&, const StringSeq&, Int, const Current&); - + virtual void detachRemoteLogger(const RemoteLoggerPrx&, const Current&); - + virtual LogMessageSeq getLog(const LogMessageTypeSeq&, const StringSeq&, Int, string&, const Current&); - + void destroy(); vector<RemoteLoggerPrx> log(const LogMessage&); - + void deadRemoteLogger(const RemoteLoggerPrx&, const LoggerPtr&, const LocalException&, const string&); const int getTraceLevel() const @@ -57,9 +57,9 @@ public: } private: - + bool removeRemoteLogger(const RemoteLoggerPrx&); - + void remoteCallCompleted(const AsyncResultPtr&); IceUtil::Mutex _mutex; @@ -69,19 +69,19 @@ private: int _traceCount; const int _maxTraceCount; const int _traceLevel; - + list<LogMessage>::iterator _oldestTrace; list<LogMessage>::iterator _oldestLog; struct ObjectIdentityCompare { - bool operator()(const RemoteLoggerPrx& lhs, const RemoteLoggerPrx& rhs) + bool operator()(const RemoteLoggerPrx& lhs, const RemoteLoggerPrx& rhs) const { // // Caller should make sure that proxies are never null // assert(lhs != 0 && rhs != 0); - + return lhs->ice_getIdentity() < rhs->ice_getIdentity(); } }; @@ -93,22 +93,22 @@ private: traceCategories(c.begin(), c.end()) { } - + const set<LogMessageType> messageTypes; const set<string> traceCategories; }; - typedef map<RemoteLoggerPrx, Filters, ObjectIdentityCompare> RemoteLoggerMap; + typedef map<RemoteLoggerPrx, Filters, ObjectIdentityCompare> RemoteLoggerMap; struct GetRemoteLoggerMapKey { - RemoteLoggerMap::key_type + RemoteLoggerMap::key_type operator()(const RemoteLoggerMap::value_type& val) { return val.first; } }; - + RemoteLoggerMap _remoteLoggerMap; const CallbackPtr _remoteCallCompleted; @@ -121,15 +121,15 @@ typedef IceUtil::Handle<LoggerAdminI> LoggerAdminIPtr; class Job : public IceUtil::Shared { public: - + Job(const vector<RemoteLoggerPrx>& r, const LogMessage& l) : remoteLoggers(r), logMessage(l) { } - + const vector<RemoteLoggerPrx> remoteLoggers; - const LogMessage logMessage; + const LogMessage logMessage; }; typedef IceUtil::Handle<Job> JobPtr; @@ -150,26 +150,26 @@ public: virtual ObjectPtr getFacet() const; virtual void destroy(); - + const LoggerPtr& getLocalLogger() const { return _localLogger; } void run(); - + private: void log(const LogMessage&); LoggerPtr _localLogger; const LoggerAdminIPtr _loggerAdmin; - + IceUtil::Monitor<IceUtil::Mutex> _monitor; bool _destroyed; IceUtil::ThreadPtr _sendLogThread; - std::deque<JobPtr> _jobQueue; + std::deque<JobPtr> _jobQueue; }; typedef IceUtil::Handle<LoggerAdminLoggerI> LoggerAdminLoggerIPtr; @@ -179,9 +179,9 @@ class SendLogThread : public IceUtil::Thread public: SendLogThread(const LoggerAdminLoggerIPtr&); - + virtual void run(); - + private: LoggerAdminLoggerIPtr _logger; @@ -195,7 +195,7 @@ private: // // Filter out messages from in/out logMessages list // -void +void filterLogMessages(LogMessageSeq& logMessages, const set<LogMessageType>& messageTypes, const set<string>& traceCategories, Int messageMax) { @@ -217,7 +217,7 @@ filterLogMessages(LogMessageSeq& logMessages, const set<LogMessageType>& message bool keepIt = false; if(messageTypes.empty() || messageTypes.count(p->type) != 0) { - if(p->type != TraceMessage || traceCategories.empty() || + if(p->type != TraceMessage || traceCategories.empty() || traceCategories.count(p->traceCategory) != 0) { keepIt = true; @@ -268,7 +268,7 @@ changeCommunicator(const RemoteLoggerPrx& prx, const CommunicatorPtr& communicat } // -// Copies a set of properties +// Copies a set of properties // void copyProperties(const string& prefix, const PropertiesPtr& from, const PropertiesPtr& to) @@ -297,7 +297,7 @@ createSendLogCommunicator(const CommunicatorPtr& communicator, const LoggerPtr& copyProperties("IceSSL.", mainProps, initData.properties); StringSeq extraProps = mainProps->getPropertyAsList("Ice.Admin.Logger.Properties"); - + if(!extraProps.empty()) { for(vector<string>::iterator p = extraProps.begin(); p != extraProps.end(); ++p) @@ -329,17 +329,17 @@ LoggerAdminI::LoggerAdminI(const PropertiesPtr& props) : } void -LoggerAdminI::attachRemoteLogger(const RemoteLoggerPrx& prx, - const LogMessageTypeSeq& messageTypes, +LoggerAdminI::attachRemoteLogger(const RemoteLoggerPrx& prx, + const LogMessageTypeSeq& messageTypes, const StringSeq& categories, - Int messageMax, + Int messageMax, const Current& current) { if(!prx) { return; // can't send this null RemoteLogger anything! } - + LoggerAdminLoggerIPtr logger = LoggerAdminLoggerIPtr::dynamicCast(current.adapter->getCommunicator()->getLogger()); if(!logger) { @@ -358,10 +358,10 @@ LoggerAdminI::attachRemoteLogger(const RemoteLoggerPrx& prx, if(!_sendLogCommunicator) { - _sendLogCommunicator = + _sendLogCommunicator = createSendLogCommunicator(current.adapter->getCommunicator(), logger->getLocalLogger()); } - + if(!_remoteLoggerMap.insert(make_pair(changeCommunicator(remoteLogger, _sendLogCommunicator), filters)).second) { if(_traceLevel > 0) @@ -378,7 +378,7 @@ LoggerAdminI::attachRemoteLogger(const RemoteLoggerPrx& prx, initLogMessages = _queue; // copy } } - + if(_traceLevel > 0) { Trace trace(logger, traceCategory); @@ -397,7 +397,7 @@ LoggerAdminI::attachRemoteLogger(const RemoteLoggerPrx& prx, throw; } } - + void LoggerAdminI::detachRemoteLogger(const RemoteLoggerPrx& remoteLogger, const Current& current) { @@ -423,24 +423,24 @@ LoggerAdminI::detachRemoteLogger(const RemoteLoggerPrx& remoteLogger, const Curr } } -LogMessageSeq -LoggerAdminI::getLog(const LogMessageTypeSeq& messageTypes, - const StringSeq& categories, +LogMessageSeq +LoggerAdminI::getLog(const LogMessageTypeSeq& messageTypes, + const StringSeq& categories, Int messageMax, string& prefix, const Current& current) { LogMessageSeq logMessages; { IceUtil::Mutex::Lock lock(_mutex); - + if(messageMax != 0) { logMessages = _queue; } } - + LoggerPtr logger = current.adapter->getCommunicator()->getLogger(); prefix = logger->getPrefix(); - + Filters filters(messageTypes, categories); filterLogMessages(logMessages, filters.messageTypes, filters.traceCategories, messageMax); return logMessages; @@ -467,11 +467,11 @@ LoggerAdminI::log(const LogMessage& logMessage) // // Put message in _queue // - if((logMessage.type != TraceMessage && _maxLogCount > 0) || - (logMessage.type == TraceMessage && _maxTraceCount > 0)) + if((logMessage.type != TraceMessage && _maxLogCount > 0) || + (logMessage.type == TraceMessage && _maxTraceCount > 0)) { list<LogMessage>::iterator p = _queue.insert(_queue.end(), logMessage); - + if(logMessage.type != TraceMessage) { assert(_maxLogCount > 0); @@ -524,18 +524,18 @@ LoggerAdminI::log(const LogMessage& logMessage) } } } - + // // Queue updated, now find which remote loggers want this message - // + // for(RemoteLoggerMap::const_iterator p = _remoteLoggerMap.begin(); p != _remoteLoggerMap.end(); ++p) { const Filters& filters = p->second; - + if(filters.messageTypes.empty() || filters.messageTypes.count(logMessage.type) != 0) { if(logMessage.type != TraceMessage || filters.traceCategories.empty() || - filters.traceCategories.count(logMessage.traceCategory) != 0) + filters.traceCategories.count(logMessage.traceCategory) != 0) { remoteLoggers.push_back(p->first); } @@ -574,7 +574,7 @@ LoggerAdminI::removeRemoteLogger(const RemoteLoggerPrx& remoteLogger) void LoggerAdminI::remoteCallCompleted(const AsyncResultPtr& r) { - try + try { r->throwLocalException(); @@ -624,7 +624,7 @@ void LoggerAdminLoggerI::print(const string& message) { LogMessage logMessage = { PrintMessage, IceUtil::Time::now().toMicroSeconds(), "", message }; - + _localLogger->print(message); log(logMessage); } @@ -633,7 +633,7 @@ void LoggerAdminLoggerI::trace(const string& category, const string& message) { LogMessage logMessage = { TraceMessage, IceUtil::Time::now().toMicroSeconds(), category, message }; - + _localLogger->trace(category, message); log(logMessage); } @@ -642,7 +642,7 @@ void LoggerAdminLoggerI::warning(const string& message) { LogMessage logMessage = { WarningMessage, IceUtil::Time::now().toMicroSeconds(), "", message }; - + _localLogger->warning(message); log(logMessage); } @@ -651,7 +651,7 @@ void LoggerAdminLoggerI::error(const string& message) { LogMessage logMessage = { ErrorMessage, IceUtil::Time::now().toMicroSeconds(), "", message }; - + _localLogger->error(message); log(logMessage); } @@ -674,15 +674,15 @@ LoggerAdminLoggerI::getFacet() const return _loggerAdmin; } -void +void LoggerAdminLoggerI::log(const LogMessage& logMessage) { - const vector<RemoteLoggerPrx> remoteLoggers = _loggerAdmin->log(logMessage); - + const vector<RemoteLoggerPrx> remoteLoggers = _loggerAdmin->log(logMessage); + if(!remoteLoggers.empty()) { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor); - + if(!_sendLogThread) { _sendLogThread = new SendLogThread(this); @@ -701,7 +701,7 @@ LoggerAdminLoggerI::destroy() bool joinThread = false; { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor); - + if(_sendLogThread) { joinThread = true; @@ -717,7 +717,7 @@ LoggerAdminLoggerI::destroy() sendLogThreadControl.join(); } - // destroy sendLogCommunicator + // destroy sendLogCommunicator _loggerAdmin->destroy(); } @@ -746,7 +746,7 @@ LoggerAdminLoggerI::run() JobPtr job = _jobQueue.front(); _jobQueue.pop_front(); lock.release(); - + for(vector<RemoteLoggerPrx>::const_iterator p = job->remoteLoggers.begin(); p != job->remoteLoggers.end(); ++p) { if(_loggerAdmin->getTraceLevel() > 1) @@ -754,7 +754,7 @@ LoggerAdminLoggerI::run() Trace trace(_localLogger, traceCategory); trace << "sending log message to `" << *p << "'"; } - + try { // @@ -766,7 +766,7 @@ LoggerAdminLoggerI::run() { _loggerAdmin->deadRemoteLogger(*p, _localLogger, ex, "log"); } - } + } } if(_loggerAdmin->getTraceLevel() > 1) @@ -786,8 +786,8 @@ SendLogThread::SendLogThread(const LoggerAdminLoggerIPtr& logger) : _logger(logger) { } - -void + +void SendLogThread::run() { _logger->run(); diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index 509ba18ad06..cd3442113f8 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -38,6 +38,7 @@ IceUtil::Shared* IceInternal::upCast(BatchOutgoingAsync* p) { return p; } IceUtil::Shared* IceInternal::upCast(ProxyBatchOutgoingAsync* p) { return p; } IceUtil::Shared* IceInternal::upCast(ConnectionBatchOutgoingAsync* p) { return p; } IceUtil::Shared* IceInternal::upCast(CommunicatorBatchOutgoingAsync* p) { return p; } +IceUtil::Shared* IceInternal::upCast(GetConnectionOutgoingAsync* p) { return p; } const unsigned char Ice::AsyncResult::OK = 0x1; const unsigned char Ice::AsyncResult::Done = 0x2; @@ -414,7 +415,7 @@ IceInternal::OutgoingAsyncMessageCallback::__dispatchInvocationTimeout(const Thr { public: - InvocationTimeoutCall(const OutgoingAsyncMessageCallbackPtr& outAsync, const Ice::ConnectionPtr& connection) : + InvocationTimeoutCall(const OutgoingAsyncMessageCallbackPtr& outAsync, const Ice::ConnectionPtr& connection) : DispatchWorkItem(connection), _outAsync(outAsync) { } @@ -901,7 +902,7 @@ IceInternal::OutgoingAsync::handleException(const Ice::Exception& exc) { int interval = _proxy->__handleException(exc, _handler, _mode, _sent, _cnt); _observer.retried(); // Invocation is being retried. - + // // Schedule the retry. Note that we always schedule the retry // on the retry queue even if the invocation can be retried @@ -928,7 +929,7 @@ IceInternal::BatchOutgoingAsync::BatchOutgoingAsync(const CommunicatorPtr& commu { } -AsyncStatus +AsyncStatus IceInternal::BatchOutgoingAsync::__send(const Ice::ConnectionIPtr& connection, bool, bool) { _cachedConnection = connection; @@ -1094,7 +1095,7 @@ IceInternal::CommunicatorBatchOutgoingAsync::CommunicatorBatchOutgoingAsync(cons // Assume all connections are flushed synchronously. // _sentSynchronously = true; - + // // Attach observer // @@ -1109,7 +1110,7 @@ IceInternal::CommunicatorBatchOutgoingAsync::flushConnection(const ConnectionIPt public: BatchOutgoingAsyncI(const CommunicatorBatchOutgoingAsyncPtr& outAsync, - const InstancePtr& instance, + const InstancePtr& instance, InvocationObserver& observer) : BatchOutgoingAsync(outAsync->getCommunicator(), instance, outAsync->getOperation(), __dummyCallback, 0), _outAsync(outAsync), _observer(observer) @@ -1141,7 +1142,7 @@ IceInternal::CommunicatorBatchOutgoingAsync::flushConnection(const ConnectionIPt } private: - + const CommunicatorBatchOutgoingAsyncPtr _outAsync; InvocationObserver& _observer; }; @@ -1181,7 +1182,7 @@ IceInternal::CommunicatorBatchOutgoingAsync::check(bool userThread) if(--_useCount > 0) { return; - } + } _state |= Done | OK | Sent; _os.resize(0); // Clear buffer now, instead of waiting for AsyncResult deallocation _monitor.notifyAll(); @@ -1207,6 +1208,96 @@ IceInternal::CommunicatorBatchOutgoingAsync::check(bool userThread) } } +IceInternal::GetConnectionOutgoingAsync::GetConnectionOutgoingAsync(const Ice::ObjectPrx& proxy, + const std::string& operation, + const CallbackBasePtr& delegate, + const Ice::LocalObjectPtr& cookie) : + OutgoingAsync(proxy, operation, delegate, cookie) +{ + _observer.attach(proxy.get(), operation, 0); +} + +void +IceInternal::GetConnectionOutgoingAsync::__invoke() +{ + while(true) + { + try + { + _handler = _proxy->__getRequestHandler(); + _handler->sendAsyncRequest(this); + } + catch(const RetryException&) + { + _proxy->__setRequestHandler(_handler, 0); + } + catch(const Ice::Exception& ex) + { + handleException(ex); + } + break; + } +} + +AsyncStatus +IceInternal::GetConnectionOutgoingAsync::__send(const Ice::ConnectionIPtr&, bool, bool) +{ + __sent(); + return AsyncStatusSent; +} + +AsyncStatus +IceInternal::GetConnectionOutgoingAsync::__invokeCollocated(CollocatedRequestHandler*) +{ + __sent(); + return AsyncStatusSent; +} + +bool +IceInternal::GetConnectionOutgoingAsync::__sent() +{ + { + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); + _state |= Done; + _monitor.notifyAll(); + } + __invokeCompleted(); + return false; +} + +void +IceInternal::GetConnectionOutgoingAsync::__invokeSent() +{ + // No sent callback +} + +void +IceInternal::GetConnectionOutgoingAsync::__finished(const Ice::Exception& exc) +{ + try + { + handleException(exc); + } + catch(const Ice::Exception& ex) + { + __invokeException(ex); + } +} + +void +IceInternal::GetConnectionOutgoingAsync::handleException(const Ice::Exception& exc) +{ + try + { + _instance->retryQueue()->add(this, _proxy->__handleException(exc, _handler, Ice::Idempotent, false, _cnt)); + _observer.retried(); // Invocation is being retried. + } + catch(const Ice::Exception& ex) + { + _observer.failed(ex.ice_name()); + throw; + } +} namespace { @@ -1227,13 +1318,13 @@ public: { } - virtual void + virtual void completed(const Ice::AsyncResultPtr&) const { assert(false); } - virtual CallbackBasePtr + virtual CallbackBasePtr verify(const Ice::LocalObjectPtr&) { // @@ -1245,13 +1336,13 @@ public: return 0; } - virtual void + virtual void sent(const AsyncResultPtr&) const { assert(false); } - virtual bool + virtual bool hasSentCallback() const { assert(false); @@ -1281,25 +1372,25 @@ Ice::newCallback(const ::IceInternal::Function<void (const AsyncResultPtr&)>& co Cpp11CB(const ::std::function<void (const AsyncResultPtr&)>& completed, const ::std::function<void (const AsyncResultPtr&)>& sent) : - _completed(completed), + _completed(completed), _sent(sent) { checkCallback(true, completed != nullptr); } - - virtual void + + virtual void completed(const AsyncResultPtr& result) const { _completed(result); } - - virtual CallbackBasePtr + + virtual CallbackBasePtr verify(const LocalObjectPtr&) { return this; // Nothing to do, the cookie is not type-safe. } - - virtual void + + virtual void sent(const AsyncResultPtr& result) const { if(_sent != nullptr) @@ -1307,19 +1398,19 @@ Ice::newCallback(const ::IceInternal::Function<void (const AsyncResultPtr&)>& co _sent(result); } } - - virtual bool + + virtual bool hasSentCallback() const { return _sent != nullptr; } - + private: ::std::function< void (const AsyncResultPtr&)> _completed; ::std::function< void (const AsyncResultPtr&)> _sent; }; - + return new Cpp11CB(completed, sent); } #endif diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 720099b6927..9878f540035 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -40,6 +40,7 @@ const string ice_ids_name = "ice_ids"; const string ice_id_name = "ice_id"; const string ice_isA_name = "ice_isA"; const string ice_invoke_name = "ice_invoke"; +const string ice_getConnection_name = "ice_getConnection"; const string ice_flushBatchRequests_name = "ice_flushBatchRequests"; } @@ -472,6 +473,49 @@ IceProxy::Ice::Object::__begin_ice_invoke( return begin_ice_invoke(operation, mode, inParams, ctx, new Cpp11CB(response, exception, sent), 0); } +Ice::AsyncResultPtr +IceProxy::Ice::Object::begin_ice_getConnection( + const ::IceInternal::Function<void (const ::Ice::ConnectionPtr&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception) +{ + class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC + { + public: + + Cpp11CB(const ::IceInternal::Function<void (const ::Ice::ConnectionPtr&)>& responseFunc, + const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc) : + ::IceInternal::Cpp11FnCallbackNC(exceptionFunc, nullptr), + _response(responseFunc) + { + CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr); + } + + virtual void completed(const ::Ice::AsyncResultPtr& __result) const + { + ::Ice::ObjectPrx __proxy = ::Ice::ObjectPrx::uncheckedCast(__result->getProxy()); + ::Ice::ConnectionPtr __ret; + try + { + __ret = __proxy->end_ice_getConnection(__result); + } + catch(const ::Ice::Exception& ex) + { + Cpp11FnCallbackNC::exception(__result, ex); + return; + } + if(_response != nullptr) + { + _response(__ret); + } + } + + private: + + ::std::function<void (const ::Ice::ConnectionPtr&)> _response; + }; + return begin_ice_getConnectionInternal(new Cpp11CB(response, exception), 0); +} + #endif @@ -1440,6 +1484,31 @@ IceProxy::Ice::Object::ice_getConnection() } } +AsyncResultPtr +IceProxy::Ice::Object::begin_ice_getConnectionInternal(const ::IceInternal::CallbackBasePtr& del, + const ::Ice::LocalObjectPtr& cookie) +{ + ::IceInternal::GetConnectionOutgoingAsyncPtr __result = + new ::IceInternal::GetConnectionOutgoingAsync(this, ice_getConnection_name, del, cookie); + try + { + __result->__invoke(); + } + catch(const Exception& __ex) + { + __result->__invokeExceptionAsync(__ex); + } + return __result; +} + +ConnectionPtr +IceProxy::Ice::Object::end_ice_getConnection(const AsyncResultPtr& __result) +{ + AsyncResult::__check(__result, this, ice_getConnection_name); + __result->__wait(); + return ice_getCachedConnection(); +} + ConnectionPtr IceProxy::Ice::Object::ice_getCachedConnection() const { diff --git a/cpp/src/Ice/RequestHandler.cpp b/cpp/src/Ice/RequestHandler.cpp index e5c7b86565c..2cbf7826213 100644 --- a/cpp/src/Ice/RequestHandler.cpp +++ b/cpp/src/Ice/RequestHandler.cpp @@ -13,8 +13,7 @@ using namespace std; using namespace IceInternal; -IceUtil::Shared* IceInternal::upCast(RequestHandler* obj) { return obj; } - +IceUtil::Shared* IceInternal::upCast(RequestHandler* p) { return p; } RetryException::RetryException(const Ice::LocalException& ex) { @@ -37,7 +36,7 @@ RequestHandler::~RequestHandler() { } -RequestHandler::RequestHandler(const ReferencePtr& reference) : +RequestHandler::RequestHandler(const ReferencePtr& reference) : _reference(reference), _response(reference->getMode() == Reference::ModeTwoway) { diff --git a/cpp/src/Ice/RequestHandler.h b/cpp/src/Ice/RequestHandler.h index e2d83c63e20..45cf917dd0a 100644 --- a/cpp/src/Ice/RequestHandler.h +++ b/cpp/src/Ice/RequestHandler.h @@ -48,7 +48,6 @@ public: private: - IceUtil::UniquePtr<Ice::LocalException> _ex; }; @@ -72,7 +71,7 @@ public: virtual Ice::ConnectionIPtr getConnection() = 0; virtual Ice::ConnectionIPtr waitForConnection() = 0; - + protected: RequestHandler(const ReferencePtr&); diff --git a/cpp/test/Ice/ami/AllTests.cpp b/cpp/test/Ice/ami/AllTests.cpp index 5cedc15abd1..c164220c2ae 100644 --- a/cpp/test/Ice/ami/AllTests.cpp +++ b/cpp/test/Ice/ami/AllTests.cpp @@ -106,6 +106,13 @@ public: called(); } + void connection(const Ice::AsyncResultPtr& result) + { + test(result->getCookie() == _cookie); + test(result->getProxy()->end_ice_getConnection(result)); + called(); + } + void op(const Ice::AsyncResultPtr& result) { test(result->getCookie() == _cookie); @@ -210,6 +217,24 @@ public: } } + void connectionEx(const Ice::AsyncResultPtr& result) + { + test(result->getCookie() == _cookie); + try + { + result->getProxy()->end_ice_getConnection(result); + test(false); + } + catch(const Ice::NoEndpointException&) + { + called(); + } + catch(const Ice::Exception&) + { + test(false); + } + } + void opEx(const Ice::AsyncResultPtr& result) { test(result->getCookie() == _cookie); @@ -265,6 +290,12 @@ public: called(); } + void connection(const Ice::ConnectionPtr& conn) + { + test(conn); + called(); + } + void op() { called(); @@ -330,6 +361,13 @@ public: called(); } + void connection(const Ice::ConnectionPtr& conn, const CookiePtr& cookie) + { + test(conn); + test(cookie == _cookie); + called(); + } + void op(const CookiePtr& cookie) { test(cookie == _cookie); @@ -395,6 +433,11 @@ public: test(false); } + void connection(const Ice::ConnectionPtr&) + { + test(false); + } + void op() { test(false); @@ -804,7 +847,7 @@ typedef IceUtil::Handle<Thrower> ThrowerPtr; } void -allTests(const Ice::CommunicatorPtr& communicator) +allTests(const Ice::CommunicatorPtr& communicator, bool collocated) { string sref = "test:default -p 12010"; Ice::ObjectPrx obj = communicator->stringToProxy(sref); @@ -843,6 +886,12 @@ allTests(const Ice::CommunicatorPtr& communicator) result = p->begin_ice_ids(ctx); test(p->end_ice_ids(result).size() == 2); + if(!collocated) + { + result = p->begin_ice_getConnection(); + test(p->end_ice_getConnection(result)); + } + result = p->begin_op(); p->end_op(result); result = p->begin_op(ctx); @@ -917,6 +966,14 @@ allTests(const Ice::CommunicatorPtr& communicator) p->begin_ice_ids(ctx, Ice::newCallback(cbWC, &AsyncCallback::ids), cookie); cbWC->check(); + if(!collocated) + { + p->begin_ice_getConnection(Ice::newCallback(cb, &AsyncCallback::connection)); + cb->check(); + p->begin_ice_getConnection(Ice::newCallback(cbWC, &AsyncCallback::connection), cookie); + cbWC->check(); + } + p->begin_op(Ice::newCallback(cb, &AsyncCallback::op)); cb->check(); p->begin_op(Ice::newCallback(cbWC, &AsyncCallback::op), cookie); @@ -945,7 +1002,7 @@ allTests(const Ice::CommunicatorPtr& communicator) cbWC->check(); } cout << "ok" << endl; - + #ifdef ICE_CPP11 cout << "testing C++11 async callback... " << flush; { @@ -972,6 +1029,12 @@ allTests(const Ice::CommunicatorPtr& communicator) p->begin_ice_ids(ctx, [=](const ::Ice::AsyncResultPtr& r){ cb->ids(r); }); cb->check(); + if(!collocated) + { + p->begin_ice_getConnection([=](const ::Ice::AsyncResultPtr& r){ cb->connection(r); }); + cb->check(); + } + p->begin_op([=](const ::Ice::AsyncResultPtr& r){ cb->op(r); }); cb->check(); p->begin_op(ctx, [=](const ::Ice::AsyncResultPtr& r){ cb->op(r); }); @@ -1040,6 +1103,16 @@ allTests(const Ice::CommunicatorPtr& communicator) p->begin_ice_ids(ctx, Ice::newCallback_Object_ice_ids(cbWC, &ResponseCallbackWC::ids, nullExWC), cookie); cbWC->check(); + if(!collocated) + { + p->begin_ice_getConnection(Ice::newCallback_Object_ice_getConnection(cb, &ResponseCallback::connection, + nullEx)); + cb->check(); + p->begin_ice_getConnection(Ice::newCallback_Object_ice_getConnection(cbWC, &ResponseCallbackWC::connection, + nullExWC), cookie); + cbWC->check(); + } + p->begin_op(Test::newCallback_TestIntf_op(cb, &ResponseCallback::op, nullEx)); cb->check(); p->begin_op(Test::newCallback_TestIntf_op(cbWC, &ResponseCallbackWC::op, nullExWC), cookie); @@ -1093,7 +1166,6 @@ allTests(const Ice::CommunicatorPtr& communicator) p->begin_ice_ping(ctx, [=](){ cb->ping(); }); cb->check(); - p->begin_ice_id([=](const string& id){ cb->id(id); }); cb->check(); @@ -1106,6 +1178,12 @@ allTests(const Ice::CommunicatorPtr& communicator) p->begin_ice_ids(ctx, [=](const Ice::StringSeq& ids){ cb->ids(ids); }); cb->check(); + if(!collocated) + { + p->begin_ice_getConnection([=](const Ice::ConnectionPtr& conn){ cb->connection(conn); }); + cb->check(); + } + p->begin_op([=](){ cb->op(); }); cb->check(); @@ -1126,7 +1204,7 @@ allTests(const Ice::CommunicatorPtr& communicator) } cout << "ok" << endl; #endif - + cout << "testing local exceptions... " << flush; { Test::TestIntfPrx indirect = Test::TestIntfPrx::uncheckedCast(p->ice_adapterId("dummy")); @@ -1201,13 +1279,19 @@ allTests(const Ice::CommunicatorPtr& communicator) i->begin_ice_ids(Ice::newCallback(cbWC, &AsyncCallback::idsEx), cookie); cbWC->check(); + if(!collocated) + { + i->begin_ice_getConnection(Ice::newCallback(cb, &AsyncCallback::connectionEx)); + cb->check(); + } + i->begin_op(Ice::newCallback(cb, &AsyncCallback::opEx)); cb->check(); i->begin_op(Ice::newCallback(cbWC, &AsyncCallback::opEx), cookie); cbWC->check(); } cout << "ok" << endl; - + cout << "testing local exceptions with response callback... " << flush; { Test::TestIntfPrx i = Test::TestIntfPrx::uncheckedCast(p->ice_adapterId("dummy")); @@ -1241,14 +1325,21 @@ allTests(const Ice::CommunicatorPtr& communicator) &ExceptionCallbackWC::ex), cookie); cbWC->check(); + if(!collocated) + { + i->begin_ice_getConnection( + Ice::newCallback_Object_ice_getConnection(cb, &ExceptionCallback::connection, &ExceptionCallback::ex)); + cb->check(); + } + i->begin_op(Test::newCallback_TestIntf_op(cb, &ExceptionCallback::op, &ExceptionCallback::ex)); cb->check(); i->begin_op(Test::newCallback_TestIntf_op(cbWC, &ExceptionCallbackWC::op, &ExceptionCallbackWC::ex), cookie); cbWC->check(); } cout << "ok" << endl; - -#ifdef ICE_CPP11 + +#ifdef ICE_CPP11 cout << "testing local exceptions with C++11 response callback... " << flush; { Test::TestIntfPrx i = Test::TestIntfPrx::uncheckedCast(p->ice_adapterId("dummy")); @@ -1266,6 +1357,13 @@ allTests(const Ice::CommunicatorPtr& communicator) i->begin_ice_ids([](const Ice::StringSeq&){ test(false); }, [=](const Ice::Exception& ex){ cb->ex(ex); }); cb->check(); + if(!collocated) + { + i->begin_ice_getConnection([](const Ice::ConnectionPtr&){ test(false); }, + [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + } + i->begin_op([](){ test(false); }, [=](const Ice::Exception& ex){ cb->ex(ex); }); cb->check(); } @@ -1320,7 +1418,7 @@ allTests(const Ice::CommunicatorPtr& communicator) cbWC->check(); } cout << "ok" << endl; - + #ifdef ICE_CPP11 cout << "testing C++11 exception callback... " << flush; { @@ -1330,6 +1428,12 @@ allTests(const Ice::CommunicatorPtr& communicator) i->begin_ice_isA(Test::TestIntf::ice_staticId(), nullptr, [=](const Ice::Exception& ex){cb->ex(ex); }); cb->check(); + if(!collocated) + { + i->begin_ice_getConnection(nullptr, [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + } + i->begin_op(nullptr, [=](const Ice::Exception& ex){ cb->ex(ex); }); cb->check(); @@ -1426,7 +1530,7 @@ allTests(const Ice::CommunicatorPtr& communicator) } } cout << "ok" << endl; - + #ifdef ICE_CPP11 cout << "testing C++11 sent callback... " << flush; { @@ -1451,7 +1555,7 @@ allTests(const Ice::CommunicatorPtr& communicator) [=](const Ice::Exception& ex){ cb->ex(ex); }, [=](bool sent){ cb->sent(sent); }); cb->check(); - + p->begin_op([=](){ cb->op(); }, [=](const Ice::Exception& ex){ cb->ex(ex); }, @@ -1646,7 +1750,7 @@ allTests(const Ice::CommunicatorPtr& communicator) } } cout << "ok" << endl; - + #ifdef ICE_CPP11 cout << "testing unexpected exceptions from C++11 callback... " << flush; { @@ -1662,7 +1766,7 @@ allTests(const Ice::CommunicatorPtr& communicator) p->begin_op([=](){ cb->op(); }, [=](const Ice::Exception& ex){ cb->ex(ex); }); cb->check(); - + p->begin_op([=](){ cb->noOp(); }, [=](const Ice::Exception& ex){ cb->noEx(ex); }, [=](bool sent){ cb->sent(sent); }); cb->check(); @@ -1799,7 +1903,7 @@ allTests(const Ice::CommunicatorPtr& communicator) test(r->isCompleted()); test(p->opBatchCount() == 0); } - + { // // Exception with cookie. @@ -1996,7 +2100,7 @@ allTests(const Ice::CommunicatorPtr& communicator) } } cout << "ok" << endl; - + #ifdef ICE_CPP11 cout << "testing C++11 batch requests with connection... " << flush; { @@ -2464,7 +2568,7 @@ allTests(const Ice::CommunicatorPtr& communicator) { test((r1->sentSynchronously() && r1->isSent() && !r1->isCompleted()) || (!r1->sentSynchronously() && !r1->isCompleted())); - + test(!r2->sentSynchronously() && !r2->isCompleted()); } } @@ -2569,9 +2673,9 @@ allTests(const Ice::CommunicatorPtr& communicator) // // Send multiple opWithPayload, followed by a close and followed by multiple opWithPaylod. - // The goal is to make sure that none of the opWithPayload fail even if the server closes + // The goal is to make sure that none of the opWithPayload fail even if the server closes // the connection gracefully in between. - // + // int maxQueue = 2; bool done = false; while(!done && maxQueue < 50) @@ -2597,7 +2701,7 @@ allTests(const Ice::CommunicatorPtr& communicator) } } } - else + else { maxQueue *= 2; done = false; diff --git a/cpp/test/Ice/ami/Client.cpp b/cpp/test/Ice/ami/Client.cpp index 9559b4d5c45..fa982d492ec 100644 --- a/cpp/test/Ice/ami/Client.cpp +++ b/cpp/test/Ice/ami/Client.cpp @@ -18,8 +18,8 @@ using namespace std; int run(int, char**, const Ice::CommunicatorPtr& communicator) { - void allTests(const Ice::CommunicatorPtr&); - allTests(communicator); + void allTests(const Ice::CommunicatorPtr&, bool); + allTests(communicator, false); return EXIT_SUCCESS; } diff --git a/cpp/test/Ice/ami/Collocated.cpp b/cpp/test/Ice/ami/Collocated.cpp index 45236ebef71..e687181b158 100644 --- a/cpp/test/Ice/ami/Collocated.cpp +++ b/cpp/test/Ice/ami/Collocated.cpp @@ -34,8 +34,8 @@ run(int, char**, const Ice::CommunicatorPtr& communicator, adapter2->add(testController, communicator->stringToIdentity("testController")); adapter2->activate(); - void allTests(const Ice::CommunicatorPtr&); - allTests(communicator); + void allTests(const Ice::CommunicatorPtr&, bool); + allTests(communicator, true); return EXIT_SUCCESS; } |