diff --git a/Net/include/Poco/Net/ParallelSocketAcceptor.h b/Net/include/Poco/Net/ParallelSocketAcceptor.h index 54c53030d..c6dfd412f 100644 --- a/Net/include/Poco/Net/ParallelSocketAcceptor.h +++ b/Net/include/Poco/Net/ParallelSocketAcceptor.h @@ -57,7 +57,9 @@ public: using Observer = Poco::Observer; explicit ParallelSocketAcceptor(ServerSocket& socket, - unsigned threads = Poco::Environment::processorCount()): + unsigned threads = Poco::Environment::processorCount(), + const std::string& threadName = ""): + _threadName(threadName), _socket(socket), _pReactor(0), _threads(threads), @@ -70,7 +72,8 @@ public: ParallelSocketAcceptor(ServerSocket& socket, SocketReactor& reactor, - unsigned threads = Poco::Environment::processorCount()): + unsigned threads = Poco::Environment::processorCount(), const std::string& threadName = ""): + _threadName(threadName), _socket(socket), _pReactor(&reactor), _threads(threads), @@ -202,7 +205,7 @@ protected: poco_assert (_threads > 0); for (unsigned i = 0; i < _threads; ++i) - _reactors.push_back(new ParallelReactor); + _reactors.push_back(new ParallelReactor(_threadName + "#" + std::to_string(i))); } ReactorVec& reactors() @@ -228,6 +231,8 @@ private: ParallelSocketAcceptor(const ParallelSocketAcceptor&); ParallelSocketAcceptor& operator = (const ParallelSocketAcceptor&); + std::string _threadName; + /// Name prefix of sub SocketReactor threads ServerSocket _socket; SocketReactor* _pReactor; unsigned _threads; diff --git a/Net/include/Poco/Net/ParallelSocketReactor.h b/Net/include/Poco/Net/ParallelSocketReactor.h index 2c268cad0..7bc6e2112 100644 --- a/Net/include/Poco/Net/ParallelSocketReactor.h +++ b/Net/include/Poco/Net/ParallelSocketReactor.h @@ -48,15 +48,19 @@ class ParallelSocketReactor: public SR public: using Ptr = Poco::SharedPtr; - ParallelSocketReactor() + ParallelSocketReactor(const std::string& threadName = "") { _thread.start(*this); + if (!threadName.empty()) + _thread.setName(threadName); } - ParallelSocketReactor(const Poco::Timespan& timeout): + ParallelSocketReactor(const Poco::Timespan& timeout, const std::string& threadName = ""): SR(timeout) { _thread.start(*this); + if (!threadName.empty()) + _thread.setName(threadName); } ~ParallelSocketReactor()