summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/interceptor/MyObjectI.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2015-12-17 17:52:44 +0100
committerJose <jose@zeroc.com>2015-12-17 17:52:44 +0100
commit061e8b03290cd88b14943b30a372a28f3a7365e0 (patch)
tree0a0a2b10b9fc1f835c6ada152049d6848a92a28f /cpp/test/Ice/interceptor/MyObjectI.cpp
parentFix Python Ice/slicing/objects test (diff)
downloadice-061e8b03290cd88b14943b30a372a28f3a7365e0.tar.bz2
ice-061e8b03290cd88b14943b30a372a28f3a7365e0.tar.xz
ice-061e8b03290cd88b14943b30a372a28f3a7365e0.zip
C++11 DispatchInterceptor fixes
Diffstat (limited to 'cpp/test/Ice/interceptor/MyObjectI.cpp')
-rw-r--r--cpp/test/Ice/interceptor/MyObjectI.cpp109
1 files changed, 109 insertions, 0 deletions
diff --git a/cpp/test/Ice/interceptor/MyObjectI.cpp b/cpp/test/Ice/interceptor/MyObjectI.cpp
index 7b89d4a3534..b007ff938eb 100644
--- a/cpp/test/Ice/interceptor/MyObjectI.cpp
+++ b/cpp/test/Ice/interceptor/MyObjectI.cpp
@@ -77,9 +77,117 @@ MyObjectI::badSystemAdd(int, int, const Ice::Current&)
{
throw MySystemException(__FILE__, __LINE__);
}
+
+#ifdef ICE_CPP11_MAPPING
+void
+MyObjectI::amdAdd_async(int x,
+ int y,
+ function<void (int)> response,
+ function<void (exception_ptr)>,
+ const Ice::Current&)
+{
+ thread t(
+ [x, y, response]()
+ {
+ this_thread::sleep_for(chrono::milliseconds(10));
+ response(x + y);
+ });
+ t.detach();
+}
+
+void
+MyObjectI::amdAddWithRetry_async(int x,
+ int y,
+ function<void (int)> response,
+ function<void (exception_ptr)>,
+ const Ice::Current& current)
+{
+ thread t(
+ [x, y, response]()
+ {
+ this_thread::sleep_for(chrono::milliseconds(10));
+ response(x + y);
+ });
+ t.detach();
+
+ Ice::Context::const_iterator p = current.ctx.find("retry");
+ if(p == current.ctx.end() || p->second != "no")
+ {
+ throw Test::RetryException(__FILE__, __LINE__);
+ }
+}
+
+void
+MyObjectI::amdBadAdd_async(int x,
+ int y,
+ function<void (int)>,
+ function<void (exception_ptr)> error,
+ const Ice::Current&)
+{
+ thread t(
+ [x, y, error]()
+ {
+ this_thread::sleep_for(chrono::milliseconds(10));
+ try
+ {
+ throw Test::InvalidInputException();
+ }
+ catch(...)
+ {
+ error(current_exception());
+ }
+ });
+ t.detach();
+}
void
+MyObjectI::amdNotExistAdd_async(int x,
+ int y,
+ function<void (int)>,
+ function<void (exception_ptr)> error,
+ const Ice::Current&)
+{
+ thread t(
+ [x, y, error]()
+ {
+ this_thread::sleep_for(chrono::milliseconds(10));
+ try
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
+ catch(...)
+ {
+ error(current_exception());
+ }
+ });
+ t.detach();
+}
+
+void
+MyObjectI::amdBadSystemAdd_async(int x,
+ int y,
+ function<void (int)>,
+ function<void (exception_ptr)> error,
+ const Ice::Current&)
+{
+ thread t(
+ [x, y, error]()
+ {
+ this_thread::sleep_for(chrono::milliseconds(10));
+ try
+ {
+ throw MySystemException(__FILE__, __LINE__);
+ }
+ catch(...)
+ {
+ error(current_exception());
+ }
+ });
+ t.detach();
+}
+#else
+void
MyObjectI::amdAdd_async(const Test::AMD_MyObject_amdAddPtr& cb, int x, int y, const Ice::Current&)
{
class ThreadI : public Thread
@@ -219,3 +327,4 @@ MyObjectI::amdBadSystemAdd_async(const Test::AMD_MyObject_amdBadSystemAddPtr& cb
ThreadPtr thread = new ThreadI(cb);
thread->start().detach();
}
+#endif