summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/AsyncResult.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-01-08 21:10:14 +0100
committerJose <jose@zeroc.com>2016-01-08 21:10:14 +0100
commit93ab5a8f08970ad49c6f973b965b8fbefb63882f (patch)
tree18c00abdc514ca90a7ab6e1acc5b350847843681 /cpp/src/Ice/AsyncResult.cpp
parentC++98 test minor build fix (diff)
downloadice-93ab5a8f08970ad49c6f973b965b8fbefb63882f.tar.bz2
ice-93ab5a8f08970ad49c6f973b965b8fbefb63882f.tar.xz
ice-93ab5a8f08970ad49c6f973b965b8fbefb63882f.zip
C++11 fix Exception::ice_clone to use exception_ptr
Diffstat (limited to 'cpp/src/Ice/AsyncResult.cpp')
-rw-r--r--cpp/src/Ice/AsyncResult.cpp40
1 files changed, 32 insertions, 8 deletions
diff --git a/cpp/src/Ice/AsyncResult.cpp b/cpp/src/Ice/AsyncResult.cpp
index 8eb8c862f1f..5848747810e 100644
--- a/cpp/src/Ice/AsyncResult.cpp
+++ b/cpp/src/Ice/AsyncResult.cpp
@@ -87,7 +87,7 @@ void
AsyncResult::waitForSent()
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
- while(!(_state & Sent) && !_exception.get())
+ while(!(_state & Sent) && !ICE_EXCEPTION_GET(_exception))
{
_monitor.wait();
}
@@ -97,9 +97,9 @@ void
AsyncResult::throwLocalException() const
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
- if(_exception.get())
+ if(ICE_EXCEPTION_GET(_exception))
{
- _exception.get()->ice_throw();
+ ICE_RETHROW_EXCEPTION(_exception);
}
}
@@ -151,10 +151,12 @@ AsyncResult::__wait()
{
_monitor.wait();
}
- if(_exception.get())
+
+ if(ICE_EXCEPTION_GET(_exception))
{
- _exception.get()->ice_throw();
+ ICE_RETHROW_EXCEPTION(_exception);
}
+
return _state & OK;
}
@@ -257,8 +259,7 @@ bool
AsyncResult::sent(bool done)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
- assert(!_exception.get());
-
+ assert(!ICE_EXCEPTION_GET(_exception));
bool alreadySent = _state & Sent;
_state |= Sent;
if(done)
@@ -298,7 +299,11 @@ AsyncResult::finished(const Ice::Exception& ex)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
_state |= Done;
+#ifdef ICE_CPP11_MAPPING
+ _exception = ex.ice_clone();
+#else
_exception.reset(ex.ice_clone());
+#endif
_cancellationHandler = 0;
_observer.failed(ex.ice_name());
if(!_callback)
@@ -433,7 +438,11 @@ AsyncResult::cancel(const Ice::LocalException& ex)
CancellationHandlerPtr handler;
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
- _cancellationException.reset(ex.ice_clone());
+#ifdef ICE_CPP11_MAPPING
+ _cancellationException = ex.ice_clone();
+#else
+ _cancellationException.reset(ex.ice_clone());
+#endif
if(!_cancellationHandler)
{
return;
@@ -451,6 +460,20 @@ void
AsyncResult::cancelable(const CancellationHandlerPtr& handler)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
+#ifdef ICE_CPP11_MAPPING
+ if(_cancellationException)
+ {
+ try
+ {
+ rethrow_exception(_cancellationException);
+ }
+ catch(const Ice::Exception&)
+ {
+ _cancellationException = nullptr;
+ throw;
+ }
+ }
+#else
if(_cancellationException.get())
{
try
@@ -463,6 +486,7 @@ AsyncResult::cancelable(const CancellationHandlerPtr& handler)
throw;
}
}
+#endif
_cancellationHandler = handler;
}