diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2014-09-19 11:24:12 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2014-09-19 11:24:12 -0230 |
commit | f684ea538bec2af9e3c10c93b3ae0341a0689ef0 (patch) | |
tree | de62e0ea13269c0ddfd4222b2f6433aaa8d77904 /cpp | |
parent | adding collocated version of Python ami test (diff) | |
download | ice-f684ea538bec2af9e3c10c93b3ae0341a0689ef0.tar.bz2 ice-f684ea538bec2af9e3c10c93b3ae0341a0689ef0.tar.xz ice-f684ea538bec2af9e3c10c93b3ae0341a0689ef0.zip |
ICE-5661 some changes to class structure for OutgoingAsync
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/include/Ice/OutgoingAsync.h | 24 | ||||
-rw-r--r-- | cpp/src/Ice/OutgoingAsync.cpp | 54 | ||||
-rw-r--r-- | cpp/src/Ice/RetryQueue.cpp | 17 | ||||
-rw-r--r-- | cpp/src/Ice/RetryQueue.h | 18 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 4 |
5 files changed, 88 insertions, 29 deletions
diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index 507ead6df62..a6718de1fe6 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -231,6 +231,11 @@ public: virtual void __finished(const Ice::Exception&) = 0; // + // Called by the retry queue to process retry. + // + virtual void __processRetry(bool destroyed) = 0; + + // // Helper to dispatch invocation timeout. // void __dispatchInvocationTimeout(const ThreadPoolPtr&, const Ice::ConnectionPtr&); @@ -255,6 +260,7 @@ public: virtual bool __sent(); virtual void __invokeSent(); virtual void __finished(const Ice::Exception&); + virtual void __processRetry(bool); virtual void __invokeExceptionAsync(const Ice::Exception&); bool __finished(); @@ -294,8 +300,6 @@ public: protected: Ice::ObjectPrx _proxy; - RequestHandlerPtr _handler; - int _cnt; private: @@ -304,6 +308,8 @@ private: Ice::EncodingVersion _encoding; + RequestHandlerPtr _handler; + int _cnt; bool _sent; Ice::OperationMode _mode; }; @@ -320,6 +326,7 @@ public: virtual bool __sent(); virtual void __invokeSent(); virtual void __finished(const Ice::Exception&); + virtual void __processRetry(bool); }; class ICE_API ProxyBatchOutgoingAsync : public BatchOutgoingAsync @@ -375,7 +382,7 @@ private: int _useCount; }; -class ICE_API GetConnectionOutgoingAsync : public OutgoingAsync +class ICE_API GetConnectionOutgoingAsync : public OutgoingAsyncMessageCallback, public Ice::AsyncResult { public: @@ -384,15 +391,26 @@ public: void __invoke(); + virtual Ice::ObjectPrx + getProxy() const + { + return _proxy; + } + virtual AsyncStatus __send(const Ice::ConnectionIPtr&, bool, bool); virtual AsyncStatus __invokeCollocated(CollocatedRequestHandler*); virtual bool __sent(); virtual void __invokeSent(); virtual void __finished(const Ice::Exception&); + virtual void __processRetry(bool); private: void handleException(const Ice::Exception&); + + Ice::ObjectPrx _proxy; + RequestHandlerPtr _handler; + int _cnt; }; // diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index cd3442113f8..c03cdd5a441 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -618,6 +618,26 @@ IceInternal::OutgoingAsync::__finished(const Ice::Exception& exc) } void +IceInternal::OutgoingAsync::__processRetry(bool destroyed) +{ + if(destroyed) + { + __invokeExceptionAsync(CommunicatorDestroyedException(__FILE__, __LINE__)); + } + else + { + try + { + __invoke(false); + } + catch(const Ice::LocalException& ex) + { + __invokeExceptionAsync(ex); + } + } +} + +void IceInternal::OutgoingAsync::__invokeExceptionAsync(const Ice::Exception& ex) { if((_state & Done) == 0 && _handler) @@ -986,6 +1006,12 @@ IceInternal::BatchOutgoingAsync::__finished(const Ice::Exception& exc) __invokeException(exc); } +void +IceInternal::BatchOutgoingAsync::__processRetry(bool destroyed) +{ + // Does not support retry +} + IceInternal::ProxyBatchOutgoingAsync::ProxyBatchOutgoingAsync(const Ice::ObjectPrx& proxy, const std::string& operation, const CallbackBasePtr& delegate, @@ -1208,13 +1234,15 @@ IceInternal::CommunicatorBatchOutgoingAsync::check(bool userThread) } } -IceInternal::GetConnectionOutgoingAsync::GetConnectionOutgoingAsync(const Ice::ObjectPrx& proxy, +IceInternal::GetConnectionOutgoingAsync::GetConnectionOutgoingAsync(const Ice::ObjectPrx& prx, const std::string& operation, const CallbackBasePtr& delegate, const Ice::LocalObjectPtr& cookie) : - OutgoingAsync(proxy, operation, delegate, cookie) + AsyncResult(prx->ice_getCommunicator(), prx->__reference()->getInstance(), operation, delegate, cookie), + _proxy(prx), + _cnt(0) { - _observer.attach(proxy.get(), operation, 0); + _observer.attach(prx.get(), operation, 0); } void @@ -1285,6 +1313,26 @@ IceInternal::GetConnectionOutgoingAsync::__finished(const Ice::Exception& exc) } void +IceInternal::GetConnectionOutgoingAsync::__processRetry(bool destroyed) +{ + if(destroyed) + { + __invokeExceptionAsync(CommunicatorDestroyedException(__FILE__, __LINE__)); + } + else + { + try + { + __invoke(); + } + catch(const Ice::LocalException& ex) + { + __invokeExceptionAsync(ex); + } + } +} + +void IceInternal::GetConnectionOutgoingAsync::handleException(const Ice::Exception& exc) { try diff --git a/cpp/src/Ice/RetryQueue.cpp b/cpp/src/Ice/RetryQueue.cpp index e10c09b1396..730b15ba73d 100644 --- a/cpp/src/Ice/RetryQueue.cpp +++ b/cpp/src/Ice/RetryQueue.cpp @@ -18,7 +18,7 @@ using namespace IceInternal; IceUtil::Shared* IceInternal::upCast(RetryQueue* p) { return p; } -IceInternal::RetryTask::RetryTask(const RetryQueuePtr& queue, const OutgoingAsyncPtr& outAsync) : +IceInternal::RetryTask::RetryTask(const RetryQueuePtr& queue, const OutgoingAsyncMessageCallbackPtr& outAsync) : _queue(queue), _outAsync(outAsync) { } @@ -28,21 +28,14 @@ IceInternal::RetryTask::runTimerTask() { if(_queue->remove(this)) { - try - { - _outAsync->__invoke(false); - } - catch(const Ice::LocalException& ex) - { - _outAsync->__invokeExceptionAsync(ex); - } + _outAsync->__processRetry(false); } } void IceInternal::RetryTask::destroy() { - _outAsync->__invokeExceptionAsync(CommunicatorDestroyedException(__FILE__, __LINE__)); + _outAsync->__processRetry(true); } bool @@ -56,7 +49,7 @@ IceInternal::RetryQueue::RetryQueue(const InstancePtr& instance) : _instance(ins } void -IceInternal::RetryQueue::add(const OutgoingAsyncPtr& out, int interval) +IceInternal::RetryQueue::add(const OutgoingAsyncMessageCallbackPtr& out, int interval) { Lock sync(*this); RetryTaskPtr task = new RetryTask(this, out); @@ -66,7 +59,7 @@ IceInternal::RetryQueue::add(const OutgoingAsyncPtr& out, int interval) } catch(const IceUtil::IllegalArgumentException&) // Expected if the communicator destroyed the timer. { - throw CommunicatorDestroyedException(__FILE__, __LINE__); + throw CommunicatorDestroyedException(__FILE__, __LINE__); } _requests.insert(task); } diff --git a/cpp/src/Ice/RetryQueue.h b/cpp/src/Ice/RetryQueue.h index 2270363c841..4339a7765b2 100644 --- a/cpp/src/Ice/RetryQueue.h +++ b/cpp/src/Ice/RetryQueue.h @@ -23,18 +23,18 @@ namespace IceInternal class RetryTask : public IceUtil::TimerTask { public: - - RetryTask(const RetryQueuePtr&, const OutgoingAsyncPtr&); - + + RetryTask(const RetryQueuePtr&, const OutgoingAsyncMessageCallbackPtr&); + virtual void runTimerTask(); void destroy(); - + bool operator<(const RetryTask&) const; - + private: - + const RetryQueuePtr _queue; - const OutgoingAsyncPtr _outAsync; + const OutgoingAsyncMessageCallbackPtr _outAsync; }; typedef IceUtil::Handle<RetryTask> RetryTaskPtr; @@ -43,8 +43,8 @@ class RetryQueue : public IceUtil::Shared, public IceUtil::Mutex public: RetryQueue(const InstancePtr&); - - void add(const OutgoingAsyncPtr&, int); + + void add(const OutgoingAsyncMessageCallbackPtr&, int); void destroy(); private: diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 9de67726eb9..9889c96a214 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -4740,8 +4740,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << sb; if(op->returnsData()) { - out << nl << "IceInternal.AsyncResultI __result = (IceInternal.AsyncResultI)__iresult;"; - out << nl << "IceInternal.AsyncResultI.check(__result, this, __" << op->name() << "_name);"; + out << nl << "IceInternal.OutgoingAsyncBase __result = (IceInternal.OutgoingAsyncBase)__iresult;"; + out << nl << "IceInternal.OutgoingAsyncBase.check(__result, this, __" << op->name() << "_name);"; out << nl << "try"; out << sb; |