diff options
author | Jose <jose@zeroc.com> | 2015-12-15 18:35:14 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2015-12-15 18:35:14 +0100 |
commit | de0939c485861ad124f64e213883c74571eefa2b (patch) | |
tree | c6dc163ddcee5aa0d878eb2463b57fc6a32a5f47 /cpp/test/Ice/dispatcher/Client.cpp | |
parent | Removed iOS workaround from udp test (diff) | |
download | ice-de0939c485861ad124f64e213883c74571eefa2b.tar.bz2 ice-de0939c485861ad124f64e213883c74571eefa2b.tar.xz ice-de0939c485861ad124f64e213883c74571eefa2b.zip |
C++11 mapping: fixes to InitializationData
Diffstat (limited to 'cpp/test/Ice/dispatcher/Client.cpp')
-rw-r--r-- | cpp/test/Ice/dispatcher/Client.cpp | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/cpp/test/Ice/dispatcher/Client.cpp b/cpp/test/Ice/dispatcher/Client.cpp index 4292b7a3398..5bdcdfd2af2 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,7 +63,13 @@ main(int argc, char* argv[]) // initData.properties->setProperty("Ice.TCP.SndSize", "50000"); -#ifdef ICE_CPP11_COMPILER +#if defined(ICE_CPP11_MAPPING) + Ice::DispatcherPtr dispatcher = new Dispatcher(); + initData.dispatcher = [=](function<void ()> call, const shared_ptr<Ice::Connection>& conn) + { + dispatcher->dispatch(new DispatcherCall(call), conn); + }; +#elif defined(ICE_CPP11_COMPILER) Ice::DispatcherPtr dispatcher = new Dispatcher(); initData.dispatcher = Ice::newDispatcher( [=](const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr& conn) @@ -54,27 +79,14 @@ main(int argc, char* argv[]) #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; } |