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/src | |
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/src')
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Ice/BatchRequestQueue.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/BatchRequestQueue.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/Initialize.cpp | 18 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 9 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 24 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.h | 4 |
8 files changed, 73 insertions, 2 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 7dabb6cd7e4..4e3de10edc8 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -2805,7 +2805,11 @@ IceInternal::BasicStream::EncapsDecoder11::readInstance(Int index, PatchFunc pat startSlice(); const string mostDerivedId = _current->typeId; Ice::ValuePtr v; +#ifdef ICE_CPP11_MAPPING + function<string (int)> compactIdResolver = _stream->instance()->initializationData().compactIdResolver; +#else const CompactIdResolverPtr& compactIdResolver = _stream->instance()->initializationData().compactIdResolver; +#endif while(true) { if(_current->compactId >= 0) @@ -2818,7 +2822,11 @@ IceInternal::BasicStream::EncapsDecoder11::readInstance(Int index, PatchFunc pat { try { +#ifdef ICE_CPP11_MAPPING + _current->typeId = compactIdResolver(_current->compactId); +#else _current->typeId = compactIdResolver->resolve(_current->compactId); +#endif } catch(const LocalException&) { diff --git a/cpp/src/Ice/BatchRequestQueue.cpp b/cpp/src/Ice/BatchRequestQueue.cpp index 04bee6e06d5..4f1c39c234f 100644 --- a/cpp/src/Ice/BatchRequestQueue.cpp +++ b/cpp/src/Ice/BatchRequestQueue.cpp @@ -127,7 +127,11 @@ BatchRequestQueue::finishBatchRequest(BasicStream* os, const Ice::ObjectPrxPtr& if(_interceptor) { BatchRequestI request(*this, proxy, operation, static_cast<int>(_batchStream.b.size() - _batchMarker)); +#ifdef ICE_CPP11_MAPPING + _interceptor(request, _batchRequestNum, static_cast<int>(_batchMarker)); +#else _interceptor->enqueue(request, _batchRequestNum, static_cast<int>(_batchMarker)); +#endif } else { diff --git a/cpp/src/Ice/BatchRequestQueue.h b/cpp/src/Ice/BatchRequestQueue.h index e562e637197..359113a7973 100644 --- a/cpp/src/Ice/BatchRequestQueue.h +++ b/cpp/src/Ice/BatchRequestQueue.h @@ -44,7 +44,11 @@ private: void waitStreamInUse(bool); +#ifdef ICE_CPP11_MAPPING + std::function<void(const Ice::BatchRequest&, int, int)> _interceptor; +#else Ice::BatchRequestInterceptorPtr _interceptor; +#endif BasicStream _batchStream; bool _batchStreamInUse; bool _batchStreamCanFlush; diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp index ebc2026d990..28cc59d3df0 100644 --- a/cpp/src/Ice/Initialize.cpp +++ b/cpp/src/Ice/Initialize.cpp @@ -140,9 +140,23 @@ Ice::createProperties(int& argc, char* argv[], const PropertiesPtr& defaults) return properties; } +#ifdef ICE_CPP11_MAPPING +Ice::ThreadHookPlugin::ThreadHookPlugin(const CommunicatorPtr& communicator, + function<void()> threadStart, + function<void()> threadStop) +{ + if(communicator == nullptr) + { + throw PluginInitializationException(__FILE__, __LINE__, "Communicator cannot be null"); + } + + IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); + instance->setThreadHook(move(threadStart), move(threadStop)); +} +#else Ice::ThreadHookPlugin::ThreadHookPlugin(const CommunicatorPtr& communicator, const ThreadNotificationPtr& threadHook) { - if(communicator == ICE_NULLPTR) + if(communicator == 0) { throw PluginInitializationException(__FILE__, __LINE__, "Communicator cannot be null"); } @@ -150,7 +164,7 @@ Ice::ThreadHookPlugin::ThreadHookPlugin(const CommunicatorPtr& communicator, con IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); instance->setThreadHook(threadHook); } - +#endif void Ice::ThreadHookPlugin::initialize() { diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index e94431d3a2d..bcc79091555 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -1043,6 +1043,14 @@ IceInternal::Instance::setLogger(const Ice::LoggerPtr& logger) _initData.logger = logger; } +#ifdef ICE_CPP11_MAPPING +void +IceInternal::Instance::setThreadHook(function<void ()> threadStart, function<void ()> threadStop) +{ + _initData.threadStart = move(threadStart); + _initData.threadStop = move(threadStop); +} +#else void IceInternal::Instance::setThreadHook(const Ice::ThreadNotificationPtr& threadHook) { @@ -1051,6 +1059,7 @@ IceInternal::Instance::setThreadHook(const Ice::ThreadNotificationPtr& threadHoo // _initData.threadHook = threadHook; } +#endif namespace { diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index 05b235c303b..c91e58de7f2 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -132,7 +132,11 @@ public: void setDefaultRouter(const Ice::RouterPrxPtr&); void setLogger(const Ice::LoggerPtr&); +#ifdef ICE_CPP11_MAPPING + void setThreadHook(std::function<void ()>, std::function<void ()>); +#else void setThreadHook(const Ice::ThreadNotificationPtr&); +#endif IceUtil::StringConverterPtr getStringConverter() const { return _stringConverter; } IceUtil::WstringConverterPtr getWstringConverter() const { return _wstringConverter; } diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 95ca1000e7d..2cea6bbc1ef 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -511,7 +511,15 @@ IceInternal::ThreadPool::dispatchFromThisThread(const DispatchWorkItemPtr& workI { try { +#ifdef ICE_CPP11_MAPPING + _dispatcher([workItem]() + { + workItem->run(); + }, + workItem->getConnection()); +#else _dispatcher->dispatch(workItem, workItem->getConnection()); +#endif } catch(const std::exception& ex) { @@ -1165,11 +1173,19 @@ IceInternal::ThreadPool::EventHandlerThread::setState(Ice::Instrumentation::Thre void IceInternal::ThreadPool::EventHandlerThread::run() { +#ifdef ICE_CPP11_MAPPING + if(_pool->_instance->initializationData().threadStart) +#else if(_pool->_instance->initializationData().threadHook) +#endif { try { +#ifdef ICE_CPP11_MAPPING + _pool->_instance->initializationData().threadStart(); +#else _pool->_instance->initializationData().threadHook->start(); +#endif } catch(const exception& ex) { @@ -1200,11 +1216,19 @@ IceInternal::ThreadPool::EventHandlerThread::run() _observer.detach(); +#ifdef ICE_CPP11_MAPPING + if(_pool->_instance->initializationData().threadStop) +#else if(_pool->_instance->initializationData().threadHook) +#endif { try { +#ifdef ICE_CPP11_MAPPING + _pool->_instance->initializationData().threadStop(); +#else _pool->_instance->initializationData().threadHook->stop(); +#endif } catch(const exception& ex) { diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h index c6db0465bee..3a440f5ca32 100644 --- a/cpp/src/Ice/ThreadPool.h +++ b/cpp/src/Ice/ThreadPool.h @@ -132,7 +132,11 @@ private: std::string nextThreadId(); const InstancePtr _instance; +#ifdef ICE_CPP11_MAPPING + std::function<void (std::function<void ()>, const std::shared_ptr<Ice::Connection>&)> _dispatcher; +#else const Ice::DispatcherPtr _dispatcher; +#endif ThreadPoolWorkQueuePtr _workQueue; bool _destroyed; const std::string _prefix; |