mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-20 13:53:15 +02: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
@ -349,8 +349,7 @@ void BaseIndex::Start()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_thread_sync = std::thread(&util::TraceThread, GetName(),
|
m_thread_sync = std::thread(&util::TraceThread, GetName(), [this] { ThreadSync(); });
|
||||||
std::bind(&BaseIndex::ThreadSync, this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseIndex::Stop()
|
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
|
// 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))
|
if (!gArgs.GetBoolArg("-dnsseed", DEFAULT_DNSSEED))
|
||||||
LogPrintf("DNS seeding disabled\n");
|
LogPrintf("DNS seeding disabled\n");
|
||||||
else
|
else
|
||||||
threadDNSAddressSeed = std::thread(&util::TraceThread, "dnsseed", std::bind(&CConnman::ThreadDNSAddressSeed, this));
|
threadDNSAddressSeed = std::thread(&util::TraceThread, "dnsseed", [this] { ThreadDNSAddressSeed(); });
|
||||||
|
|
||||||
// Initiate manual connections
|
// 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 (connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing.empty()) {
|
||||||
if (clientInterface) {
|
if (clientInterface) {
|
||||||
@ -2546,16 +2546,18 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (connOptions.m_use_addrman_outgoing || !connOptions.m_specified_outgoing.empty())
|
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));
|
threadOpenConnections = std::thread(
|
||||||
|
&util::TraceThread, "opencon",
|
||||||
|
[this, connect = connOptions.m_specified_outgoing] { ThreadOpenConnections(connect); });
|
||||||
|
}
|
||||||
|
|
||||||
// Process messages
|
// 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) {
|
if (connOptions.m_i2p_accept_incoming && m_i2p_sam_session.get() != nullptr) {
|
||||||
threadI2PAcceptIncoming =
|
threadI2PAcceptIncoming =
|
||||||
std::thread(&util::TraceThread, "i2paccept",
|
std::thread(&util::TraceThread, "i2paccept", [this] { ThreadI2PAcceptIncoming(); });
|
||||||
std::function<void()>(std::bind(&CConnman::ThreadI2PAcceptIncoming, this)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump network addresses
|
// Dump network addresses
|
||||||
|
Loading…
x
Reference in New Issue
Block a user