Merge branch 'devel' of https://github.com/pocoproject/poco into devel

This commit is contained in:
Alex Fabijanic
2022-06-25 20:28:37 +02:00
2 changed files with 14 additions and 5 deletions

View File

@@ -57,7 +57,9 @@ public:
using Observer = Poco::Observer<ParallelSocketAcceptor, ReadableNotification>; using Observer = Poco::Observer<ParallelSocketAcceptor, ReadableNotification>;
explicit ParallelSocketAcceptor(ServerSocket& socket, explicit ParallelSocketAcceptor(ServerSocket& socket,
unsigned threads = Poco::Environment::processorCount()): unsigned threads = Poco::Environment::processorCount(),
const std::string& threadName = ""):
_threadName(threadName),
_socket(socket), _socket(socket),
_pReactor(0), _pReactor(0),
_threads(threads), _threads(threads),
@@ -70,7 +72,8 @@ public:
ParallelSocketAcceptor(ServerSocket& socket, ParallelSocketAcceptor(ServerSocket& socket,
SocketReactor& reactor, SocketReactor& reactor,
unsigned threads = Poco::Environment::processorCount()): unsigned threads = Poco::Environment::processorCount(), const std::string& threadName = ""):
_threadName(threadName),
_socket(socket), _socket(socket),
_pReactor(&reactor), _pReactor(&reactor),
_threads(threads), _threads(threads),
@@ -202,7 +205,7 @@ protected:
poco_assert (_threads > 0); poco_assert (_threads > 0);
for (unsigned i = 0; i < _threads; ++i) for (unsigned i = 0; i < _threads; ++i)
_reactors.push_back(new ParallelReactor); _reactors.push_back(new ParallelReactor(_threadName + "#" + std::to_string(i)));
} }
ReactorVec& reactors() ReactorVec& reactors()
@@ -228,6 +231,8 @@ private:
ParallelSocketAcceptor(const ParallelSocketAcceptor&); ParallelSocketAcceptor(const ParallelSocketAcceptor&);
ParallelSocketAcceptor& operator = (const ParallelSocketAcceptor&); ParallelSocketAcceptor& operator = (const ParallelSocketAcceptor&);
std::string _threadName;
/// Name prefix of sub SocketReactor threads
ServerSocket _socket; ServerSocket _socket;
SocketReactor* _pReactor; SocketReactor* _pReactor;
unsigned _threads; unsigned _threads;

View File

@@ -48,15 +48,19 @@ class ParallelSocketReactor: public SR
public: public:
using Ptr = Poco::SharedPtr<ParallelSocketReactor>; using Ptr = Poco::SharedPtr<ParallelSocketReactor>;
ParallelSocketReactor() ParallelSocketReactor(const std::string& threadName = "")
{ {
_thread.start(*this); _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) SR(timeout)
{ {
_thread.start(*this); _thread.start(*this);
if (!threadName.empty())
_thread.setName(threadName);
} }
~ParallelSocketReactor() ~ParallelSocketReactor()