refactor: Make TraceThread a non-template free function

Also it is moved into its own module.
This commit is contained in:
Hennadii Stepanov
2021-04-13 20:44:46 +03:00
parent a1f0b8b62e
commit 30e4448215
11 changed files with 67 additions and 36 deletions

View File

@@ -23,6 +23,7 @@
#include <scheduler.h>
#include <util/sock.h>
#include <util/strencodings.h>
#include <util/thread.h>
#include <util/translation.h>
#ifdef WIN32
@@ -2527,15 +2528,15 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
}
// Send and receive from sockets, accept connections
threadSocketHandler = std::thread(&TraceThread<std::function<void()> >, "net", std::function<void()>(std::bind(&CConnman::ThreadSocketHandler, this)));
threadSocketHandler = std::thread(&util::TraceThread, "net", std::bind(&CConnman::ThreadSocketHandler, this));
if (!gArgs.GetBoolArg("-dnsseed", DEFAULT_DNSSEED))
LogPrintf("DNS seeding disabled\n");
else
threadDNSAddressSeed = std::thread(&TraceThread<std::function<void()> >, "dnsseed", std::function<void()>(std::bind(&CConnman::ThreadDNSAddressSeed, this)));
threadDNSAddressSeed = std::thread(&util::TraceThread, "dnsseed", std::bind(&CConnman::ThreadDNSAddressSeed, this));
// Initiate manual connections
threadOpenAddedConnections = std::thread(&TraceThread<std::function<void()> >, "addcon", std::function<void()>(std::bind(&CConnman::ThreadOpenAddedConnections, this)));
threadOpenAddedConnections = std::thread(&util::TraceThread, "addcon", std::bind(&CConnman::ThreadOpenAddedConnections, this));
if (connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing.empty()) {
if (clientInterface) {
@@ -2546,14 +2547,14 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
return false;
}
if (connOptions.m_use_addrman_outgoing || !connOptions.m_specified_outgoing.empty())
threadOpenConnections = std::thread(&TraceThread<std::function<void()> >, "opencon", std::function<void()>(std::bind(&CConnman::ThreadOpenConnections, this, connOptions.m_specified_outgoing)));
threadOpenConnections = std::thread(&util::TraceThread, "opencon", std::bind(&CConnman::ThreadOpenConnections, this, connOptions.m_specified_outgoing));
// Process messages
threadMessageHandler = std::thread(&TraceThread<std::function<void()> >, "msghand", std::function<void()>(std::bind(&CConnman::ThreadMessageHandler, this)));
threadMessageHandler = std::thread(&util::TraceThread, "msghand", std::bind(&CConnman::ThreadMessageHandler, this));
if (connOptions.m_i2p_accept_incoming && m_i2p_sam_session.get() != nullptr) {
threadI2PAcceptIncoming =
std::thread(&TraceThread<std::function<void()>>, "i2paccept",
std::thread(&util::TraceThread, "i2paccept",
std::function<void()>(std::bind(&CConnman::ThreadI2PAcceptIncoming, this)));
}