mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-28 16:36:04 +01:00
Merge #13743: refactor: Replace boost::bind with std::bind
cb53b825c2scripted-diff: Replace boost::bind with std::bind (Chun Kuan Lee)2196c51821refactor: Use boost::scoped_connection in signal/slot, also prefer range-based loop instead of std::transform (Chun Kuan Lee) Pull request description: Replace boost::bind with std::bind - In `src/rpc/server.cpp`, replace `std::transform` with simple loop. - In `src/validation.cpp`, store the `boost::signals2::connection` object and use it to disconnect. - In `src/validationinterface.cpp`, use 2 map to store the `boost::signals2::scoped_connection` object. Tree-SHA512: 6653cbe00036fecfc495340618efcba6d7be0227c752b37b81a27184433330f817e8de9257774e9b35828026cb55f11ee7f17d6c388aebe22c4a3df13b5092f0
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <test/test_bitcoin.h>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
@@ -21,7 +20,7 @@ static void microTask(CScheduler& s, boost::mutex& mutex, int& counter, int delt
|
||||
}
|
||||
boost::chrono::system_clock::time_point noTime = boost::chrono::system_clock::time_point::min();
|
||||
if (rescheduleTime != noTime) {
|
||||
CScheduler::Function f = boost::bind(µTask, boost::ref(s), boost::ref(mutex), boost::ref(counter), -delta + 1, noTime);
|
||||
CScheduler::Function f = std::bind(µTask, std::ref(s), std::ref(mutex), std::ref(counter), -delta + 1, noTime);
|
||||
s.schedule(f, rescheduleTime);
|
||||
}
|
||||
}
|
||||
@@ -69,8 +68,8 @@ BOOST_AUTO_TEST_CASE(manythreads)
|
||||
boost::chrono::system_clock::time_point t = now + boost::chrono::microseconds(randomMsec(rng));
|
||||
boost::chrono::system_clock::time_point tReschedule = now + boost::chrono::microseconds(500 + randomMsec(rng));
|
||||
int whichCounter = zeroToNine(rng);
|
||||
CScheduler::Function f = boost::bind(µTask, boost::ref(microTasks),
|
||||
boost::ref(counterMutex[whichCounter]), boost::ref(counter[whichCounter]),
|
||||
CScheduler::Function f = std::bind(µTask, std::ref(microTasks),
|
||||
std::ref(counterMutex[whichCounter]), std::ref(counter[whichCounter]),
|
||||
randomDelta(rng), tReschedule);
|
||||
microTasks.schedule(f, t);
|
||||
}
|
||||
@@ -82,20 +81,20 @@ BOOST_AUTO_TEST_CASE(manythreads)
|
||||
// As soon as these are created they will start running and servicing the queue
|
||||
boost::thread_group microThreads;
|
||||
for (int i = 0; i < 5; i++)
|
||||
microThreads.create_thread(boost::bind(&CScheduler::serviceQueue, µTasks));
|
||||
microThreads.create_thread(std::bind(&CScheduler::serviceQueue, µTasks));
|
||||
|
||||
MicroSleep(600);
|
||||
now = boost::chrono::system_clock::now();
|
||||
|
||||
// More threads and more tasks:
|
||||
for (int i = 0; i < 5; i++)
|
||||
microThreads.create_thread(boost::bind(&CScheduler::serviceQueue, µTasks));
|
||||
microThreads.create_thread(std::bind(&CScheduler::serviceQueue, µTasks));
|
||||
for (int i = 0; i < 100; i++) {
|
||||
boost::chrono::system_clock::time_point t = now + boost::chrono::microseconds(randomMsec(rng));
|
||||
boost::chrono::system_clock::time_point tReschedule = now + boost::chrono::microseconds(500 + randomMsec(rng));
|
||||
int whichCounter = zeroToNine(rng);
|
||||
CScheduler::Function f = boost::bind(µTask, boost::ref(microTasks),
|
||||
boost::ref(counterMutex[whichCounter]), boost::ref(counter[whichCounter]),
|
||||
CScheduler::Function f = std::bind(µTask, std::ref(microTasks),
|
||||
std::ref(counterMutex[whichCounter]), std::ref(counter[whichCounter]),
|
||||
randomDelta(rng), tReschedule);
|
||||
microTasks.schedule(f, t);
|
||||
}
|
||||
@@ -126,7 +125,7 @@ BOOST_AUTO_TEST_CASE(singlethreadedscheduler_ordered)
|
||||
// if they don't we'll get out of order behaviour
|
||||
boost::thread_group threads;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
threads.create_thread(boost::bind(&CScheduler::serviceQueue, &scheduler));
|
||||
threads.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler));
|
||||
}
|
||||
|
||||
// these are not atomic, if SinglethreadedSchedulerClient prevents
|
||||
|
||||
@@ -89,7 +89,7 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
|
||||
|
||||
// We have to run a scheduler thread to prevent ActivateBestChain
|
||||
// from blocking due to queue overrun.
|
||||
threadGroup.create_thread(boost::bind(&CScheduler::serviceQueue, &scheduler));
|
||||
threadGroup.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler));
|
||||
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
|
||||
|
||||
mempool.setSanityCheck(1.0);
|
||||
|
||||
@@ -467,7 +467,7 @@ BOOST_AUTO_TEST_CASE(test_big_witness_transaction) {
|
||||
CCheckQueueControl<CScriptCheck> control(&scriptcheckqueue);
|
||||
|
||||
for (int i=0; i<20; i++)
|
||||
threadGroup.create_thread(boost::bind(&CCheckQueue<CScriptCheck>::Thread, boost::ref(scriptcheckqueue)));
|
||||
threadGroup.create_thread(std::bind(&CCheckQueue<CScriptCheck>::Thread, std::ref(scriptcheckqueue)));
|
||||
|
||||
std::vector<Coin> coins;
|
||||
for(uint32_t i = 0; i < mtx.vin.size(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user