summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/dispatcher/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/Ice/dispatcher/Client.cpp')
-rw-r--r--cpp/test/Ice/dispatcher/Client.cpp51
1 files changed, 28 insertions, 23 deletions
diff --git a/cpp/test/Ice/dispatcher/Client.cpp b/cpp/test/Ice/dispatcher/Client.cpp
index 5065eeae945..3c4e1735e01 100644
--- a/cpp/test/Ice/dispatcher/Client.cpp
+++ b/cpp/test/Ice/dispatcher/Client.cpp
@@ -24,6 +24,27 @@ run(int, char**, const Ice::CommunicatorPtr& communicator)
return EXIT_SUCCESS;
}
+#ifdef ICE_CPP11_MAPPING
+class DispatcherCall : public Ice::DispatcherCall
+{
+public:
+
+ DispatcherCall(function<void ()> call) :
+ _call(move(call))
+ {
+ }
+
+ virtual void run()
+ {
+ _call();
+ }
+
+private:
+
+ function<void ()> _call;
+};
+#endif
+
int
main(int argc, char* argv[])
{
@@ -31,8 +52,6 @@ main(int argc, char* argv[])
Ice::registerIceSSL();
#endif
int status;
- Ice::CommunicatorPtr communicator;
-
try
{
Ice::InitializationData initData;
@@ -44,37 +63,23 @@ main(int argc, char* argv[])
//
initData.properties->setProperty("Ice.TCP.SndSize", "50000");
-#ifdef ICE_CPP11
+#ifdef ICE_CPP11_MAPPING
Ice::DispatcherPtr dispatcher = new Dispatcher();
- initData.dispatcher = Ice::newDispatcher(
- [=](const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr& conn)
- {
- dispatcher->dispatch(call, conn);
- });
+ initData.dispatcher = [=](function<void ()> call, const shared_ptr<Ice::Connection>& conn)
+ {
+ dispatcher->dispatch(new DispatcherCall(call), conn);
+ };
#else
initData.dispatcher = new Dispatcher();
#endif
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
+ status = run(argc, argv, ich.communicator());
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
status = EXIT_FAILURE;
}
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
Dispatcher::terminate();
return status;
}