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/Collocated.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/Collocated.cpp')
-rw-r--r-- | cpp/test/Ice/dispatcher/Collocated.cpp | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/cpp/test/Ice/dispatcher/Collocated.cpp b/cpp/test/Ice/dispatcher/Collocated.cpp index 34b5b235515..e76bfa09b08 100644 --- a/cpp/test/Ice/dispatcher/Collocated.cpp +++ b/cpp/test/Ice/dispatcher/Collocated.cpp @@ -26,9 +26,9 @@ run(int, char**, const Ice::CommunicatorPtr& communicator) Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter"); Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("ControllerAdapter"); - TestIntfControllerIPtr testController = new TestIntfControllerI(adapter); + TestIntfControllerIPtr testController = ICE_MAKE_SHARED(TestIntfControllerI, adapter); - adapter->add(new TestIntfI(), communicator->stringToIdentity("test")); + adapter->add(ICE_MAKE_SHARED(TestIntfI), communicator->stringToIdentity("test")); //adapter->activate(); // Don't activate OA to ensure collocation is used. adapter2->add(testController, communicator->stringToIdentity("testController")); @@ -39,6 +39,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[]) { @@ -46,13 +67,17 @@ main(int argc, char* argv[]) Ice::registerIceSSL(); #endif int status; - Ice::CommunicatorPtr communicator; - try { Ice::InitializationData initData; initData.properties = Ice::createProperties(argc, argv); -#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) @@ -62,27 +87,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; } |