mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
refactor: Replace std::bind with lambdas
Lambdas are shorter and more readable. Changes are limited to std::thread ctor calls only.
This commit is contained in:
parent
a508f718f3
commit
792be53d3e
2 changed files with 11 additions and 10 deletions
|
@ -349,8 +349,7 @@ void BaseIndex::Start()
|
|||
return;
|
||||
}
|
||||
|
||||
m_thread_sync = std::thread(&util::TraceThread, GetName(),
|
||||
std::bind(&BaseIndex::ThreadSync, this));
|
||||
m_thread_sync = std::thread(&util::TraceThread, GetName(), [this] { ThreadSync(); });
|
||||
}
|
||||
|
||||
void BaseIndex::Stop()
|
||||
|
|
18
src/net.cpp
18
src/net.cpp
|
@ -2528,15 +2528,15 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
|
|||
}
|
||||
|
||||
// Send and receive from sockets, accept connections
|
||||
threadSocketHandler = std::thread(&util::TraceThread, "net", std::bind(&CConnman::ThreadSocketHandler, this));
|
||||
threadSocketHandler = std::thread(&util::TraceThread, "net", [this] { ThreadSocketHandler(); });
|
||||
|
||||
if (!gArgs.GetBoolArg("-dnsseed", DEFAULT_DNSSEED))
|
||||
LogPrintf("DNS seeding disabled\n");
|
||||
else
|
||||
threadDNSAddressSeed = std::thread(&util::TraceThread, "dnsseed", std::bind(&CConnman::ThreadDNSAddressSeed, this));
|
||||
threadDNSAddressSeed = std::thread(&util::TraceThread, "dnsseed", [this] { ThreadDNSAddressSeed(); });
|
||||
|
||||
// Initiate manual connections
|
||||
threadOpenAddedConnections = std::thread(&util::TraceThread, "addcon", std::bind(&CConnman::ThreadOpenAddedConnections, this));
|
||||
threadOpenAddedConnections = std::thread(&util::TraceThread, "addcon", [this] { ThreadOpenAddedConnections(); });
|
||||
|
||||
if (connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing.empty()) {
|
||||
if (clientInterface) {
|
||||
|
@ -2546,16 +2546,18 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
if (connOptions.m_use_addrman_outgoing || !connOptions.m_specified_outgoing.empty())
|
||||
threadOpenConnections = std::thread(&util::TraceThread, "opencon", std::bind(&CConnman::ThreadOpenConnections, this, connOptions.m_specified_outgoing));
|
||||
if (connOptions.m_use_addrman_outgoing || !connOptions.m_specified_outgoing.empty()) {
|
||||
threadOpenConnections = std::thread(
|
||||
&util::TraceThread, "opencon",
|
||||
[this, connect = connOptions.m_specified_outgoing] { ThreadOpenConnections(connect); });
|
||||
}
|
||||
|
||||
// Process messages
|
||||
threadMessageHandler = std::thread(&util::TraceThread, "msghand", std::bind(&CConnman::ThreadMessageHandler, this));
|
||||
threadMessageHandler = std::thread(&util::TraceThread, "msghand", [this] { ThreadMessageHandler(); });
|
||||
|
||||
if (connOptions.m_i2p_accept_incoming && m_i2p_sam_session.get() != nullptr) {
|
||||
threadI2PAcceptIncoming =
|
||||
std::thread(&util::TraceThread, "i2paccept",
|
||||
std::function<void()>(std::bind(&CConnman::ThreadI2PAcceptIncoming, this)));
|
||||
std::thread(&util::TraceThread, "i2paccept", [this] { ThreadI2PAcceptIncoming(); });
|
||||
}
|
||||
|
||||
// Dump network addresses
|
||||
|
|
Loading…
Reference in a new issue