diff options
author | Jose <jose@zeroc.com> | 2018-09-07 18:47:28 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2018-09-07 18:47:28 +0200 |
commit | 8cddd264e57ab89fc4c6952b2b390457a4bfbedf (patch) | |
tree | 66bb34aa13289ed0017a9460e800740516bb1278 /cpp/src/Ice/ConnectionFactory.cpp | |
parent | Enable test workers for PHP, Ruby and Python (diff) | |
download | ice-8cddd264e57ab89fc4c6952b2b390457a4bfbedf.tar.bz2 ice-8cddd264e57ab89fc4c6952b2b390457a4bfbedf.tar.xz ice-8cddd264e57ab89fc4c6952b2b390457a4bfbedf.zip |
Fixes for C++17 mode
Close #180
Diffstat (limited to 'cpp/src/Ice/ConnectionFactory.cpp')
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 98 |
1 files changed, 87 insertions, 11 deletions
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index 744e261e3cd..cc81ec65f12 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -53,14 +53,6 @@ IceUtil::Shared* IceInternal::upCast(IncomingConnectionFactory* p) { return p; } namespace { -struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t> -{ - ptrdiff_t operator()(ptrdiff_t d) - { - return IceUtilInternal::random(static_cast<int>(d)); - } -}; - #ifdef ICE_CPP11_MAPPING template <typename Map> void remove(Map& m, const typename Map::key_type& k, const typename Map::mapped_type& v) @@ -178,10 +170,16 @@ IceInternal::OutgoingConnectionFactory::destroy() return; } +#ifdef ICE_CPP11_COMPILER + for(const auto& p : _connections) + { + p.second->destroy(ConnectionI::CommunicatorDestroyed); + } +#else for_each(_connections.begin(), _connections.end(), bind2nd(Ice::secondVoidMemFun1<const ConnectorPtr, ConnectionI, ConnectionI::DestructionReason> (&ConnectionI::destroy), ConnectionI::CommunicatorDestroyed)); - +#endif _destroyed = true; _communicator = 0; @@ -192,8 +190,15 @@ void IceInternal::OutgoingConnectionFactory::updateConnectionObservers() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); +#ifdef ICE_CPP11_COMPILER + for(const auto& p : _connections) + { + p.second->updateObserver(); + } +#else for_each(_connections.begin(), _connections.end(), Ice::secondVoidMemFun<const ConnectorPtr, ConnectionI>(&ConnectionI::updateObserver)); +#endif } void @@ -221,9 +226,15 @@ IceInternal::OutgoingConnectionFactory::waitUntilFinished() connections = _connections; } +#ifdef ICE_CPP11_COMPILER + for(const auto& p : _connections) + { + p.second->waitUntilFinished(); + } +#else for_each(connections.begin(), connections.end(), Ice::secondVoidMemFun<const ConnectorPtr, ConnectionI>(&ConnectionI::waitUntilFinished)); - +#endif { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); // Ensure all the connections are finished and reapable at this point. @@ -436,7 +447,15 @@ IceInternal::OutgoingConnectionFactory::findConnection(const vector<EndpointIPtr assert(!endpoints.empty()); for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p) { +#ifdef ICE_CPP11_MAPPING + auto connection = find(_connectionsByEndpoint, *p, + [](const ConnectionIPtr& conn) + { + return conn->isActiveOrHolding(); + }); +#else ConnectionIPtr connection = find(_connectionsByEndpoint, *p, Ice::constMemFun(&ConnectionI::isActiveOrHolding)); +#endif if(connection) { if(defaultsAndOverrides->overrideCompress) @@ -466,7 +485,15 @@ IceInternal::OutgoingConnectionFactory::findConnection(const vector<ConnectorInf continue; } +#ifdef ICE_CPP11_MAPPING + auto connection = find(_connections, p->connector, + [](const ConnectionIPtr& conn) + { + return conn->isActiveOrHolding(); + }); +#else ConnectionIPtr connection = find(_connections, p->connector, Ice::constMemFun(&ConnectionI::isActiveOrHolding)); +#endif if(connection) { if(defaultsAndOverrides->overrideCompress) @@ -1193,7 +1220,14 @@ void IceInternal::IncomingConnectionFactory::updateConnectionObservers() { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); +#ifdef ICE_CPP11_COMPILER + for(const auto& conn : _connections) + { + conn->updateObserver(); + } +#else for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::updateObserver)); +#endif } void @@ -1223,7 +1257,14 @@ IceInternal::IncomingConnectionFactory::waitUntilHolding() const // // Now we wait until each connection is in holding state. // +#ifdef ICE_CPP11_COMPILER + for(const auto& conn : connections) + { + conn->waitUntilHolding(); + } +#else for_each(connections.begin(), connections.end(), Ice::constVoidMemFun(&ConnectionI::waitUntilHolding)); +#endif } void @@ -1253,7 +1294,14 @@ IceInternal::IncomingConnectionFactory::waitUntilFinished() connections = _connections; } +#ifdef ICE_CPP11_COMPILER + for(const auto& conn : connections) + { + conn->waitUntilFinished(); + } +#else for_each(connections.begin(), connections.end(), Ice::voidMemFun(&ConnectionI::waitUntilFinished)); +#endif { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); @@ -1311,9 +1359,16 @@ IceInternal::IncomingConnectionFactory::connections() const // // Only copy connections which have not been destroyed. // +#ifdef ICE_CPP11_COMPILER + remove_copy_if(_connections.begin(), _connections.end(), back_inserter(result), + [](const ConnectionIPtr& conn) + { + return !conn->isActiveOrHolding(); + }); +#else remove_copy_if(_connections.begin(), _connections.end(), back_inserter(result), not1(Ice::constMemFun(&ConnectionI::isActiveOrHolding))); - +#endif return result; } @@ -1737,7 +1792,14 @@ IceInternal::IncomingConnectionFactory::setState(State state) } _adapter->getThreadPool()->_register(ICE_SHARED_FROM_THIS, SocketOperationRead); } +#ifdef ICE_CPP11_COMPILER + for(const auto& conn : _connections) + { + conn->activate(); + } +#else for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::activate)); +#endif break; } @@ -1756,7 +1818,14 @@ IceInternal::IncomingConnectionFactory::setState(State state) } _adapter->getThreadPool()->unregister(ICE_SHARED_FROM_THIS, SocketOperationRead); } +#ifdef ICE_CPP11_COMPILER + for(const auto& conn : _connections) + { + conn->hold(); + } +#else for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::hold)); +#endif break; } @@ -1781,8 +1850,15 @@ IceInternal::IncomingConnectionFactory::setState(State state) state = StateFinished; } +#ifdef ICE_CPP11_COMPILER + for(const auto& conn : _connections) + { + conn->destroy(ConnectionI::ObjectAdapterDeactivated); + } +#else for_each(_connections.begin(), _connections.end(), bind2nd(Ice::voidMemFun1(&ConnectionI::destroy), ConnectionI::ObjectAdapterDeactivated)); +#endif break; } |