mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-08 03:59:18 +02:00
refactor: Make move semantics explicit for callers
This commit is contained in:
parent
6c2d5972f3
commit
04831fee6d
@ -60,7 +60,7 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
|
||||
// Make insecure_rand here so that each iteration is identical.
|
||||
CCheckQueueControl<PrevectorJob> control(&queue);
|
||||
for (auto vChecks : vBatches) {
|
||||
control.Add(vChecks);
|
||||
control.Add(std::move(vChecks));
|
||||
}
|
||||
// control waits for completion by RAII, but
|
||||
// it is done explicitly here for clarity
|
||||
|
@ -166,7 +166,7 @@ public:
|
||||
}
|
||||
|
||||
//! Add a batch of checks to the queue
|
||||
void Add(std::vector<T>& vChecks) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
|
||||
void Add(std::vector<T>&& vChecks) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
|
||||
{
|
||||
if (vChecks.empty()) {
|
||||
return;
|
||||
@ -237,10 +237,11 @@ public:
|
||||
return fRet;
|
||||
}
|
||||
|
||||
void Add(std::vector<T>& vChecks)
|
||||
void Add(std::vector<T>&& vChecks)
|
||||
{
|
||||
if (pqueue != nullptr)
|
||||
pqueue->Add(vChecks);
|
||||
if (pqueue != nullptr) {
|
||||
pqueue->Add(std::move(vChecks));
|
||||
}
|
||||
}
|
||||
|
||||
~CCheckQueueControl()
|
||||
|
@ -191,7 +191,7 @@ static void Correct_Queue_range(std::vector<size_t> range)
|
||||
while (total) {
|
||||
vChecks.resize(std::min(total, (size_t) InsecureRandRange(10)));
|
||||
total -= vChecks.size();
|
||||
control.Add(vChecks);
|
||||
control.Add(std::move(vChecks));
|
||||
}
|
||||
BOOST_REQUIRE(control.Wait());
|
||||
if (FakeCheckCheckCompletion::n_calls != i) {
|
||||
@ -253,7 +253,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure)
|
||||
vChecks.reserve(r);
|
||||
for (size_t k = 0; k < r && remaining; k++, remaining--)
|
||||
vChecks.emplace_back(remaining == 1);
|
||||
control.Add(vChecks);
|
||||
control.Add(std::move(vChecks));
|
||||
}
|
||||
bool success = control.Wait();
|
||||
if (i > 0) {
|
||||
@ -278,7 +278,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure)
|
||||
std::vector<FailingCheck> vChecks;
|
||||
vChecks.resize(100, false);
|
||||
vChecks[99] = end_fails;
|
||||
control.Add(vChecks);
|
||||
control.Add(std::move(vChecks));
|
||||
}
|
||||
bool r =control.Wait();
|
||||
BOOST_REQUIRE(r != end_fails);
|
||||
@ -304,7 +304,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck)
|
||||
std::vector<UniqueCheck> vChecks;
|
||||
for (size_t k = 0; k < r && total; k++)
|
||||
vChecks.emplace_back(--total);
|
||||
control.Add(vChecks);
|
||||
control.Add(std::move(vChecks));
|
||||
}
|
||||
}
|
||||
{
|
||||
@ -342,7 +342,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory)
|
||||
// to catch any sort of deallocation failure
|
||||
vChecks.emplace_back(total == 0 || total == i || total == i/2);
|
||||
}
|
||||
control.Add(vChecks);
|
||||
control.Add(std::move(vChecks));
|
||||
}
|
||||
}
|
||||
BOOST_REQUIRE_EQUAL(MemoryCheck::fake_allocated_memory, 0U);
|
||||
@ -364,7 +364,7 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup)
|
||||
// swaps in default initialized Checks (otherwise freezing destructor
|
||||
// would get called twice).
|
||||
vChecks[0].should_freeze = true;
|
||||
control.Add(vChecks);
|
||||
control.Add(std::move(vChecks));
|
||||
bool waitResult = control.Wait(); // Hangs here
|
||||
assert(waitResult);
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ FUZZ_TARGET(checkqueue)
|
||||
checks_2.emplace_back(result);
|
||||
}
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
check_queue_1.Add(checks_1);
|
||||
check_queue_1.Add(std::move(checks_1));
|
||||
}
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
(void)check_queue_1.Wait();
|
||||
@ -56,7 +56,7 @@ FUZZ_TARGET(checkqueue)
|
||||
|
||||
CCheckQueueControl<DumbCheck> check_queue_control{&check_queue_2};
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
check_queue_control.Add(checks_2);
|
||||
check_queue_control.Add(std::move(checks_2));
|
||||
}
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
(void)check_queue_control.Wait();
|
||||
|
@ -548,7 +548,7 @@ BOOST_AUTO_TEST_CASE(test_big_witness_transaction)
|
||||
for(uint32_t i = 0; i < mtx.vin.size(); i++) {
|
||||
std::vector<CScriptCheck> vChecks;
|
||||
vChecks.emplace_back(coins[tx.vin[i].prevout.n].out, tx, i, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS, false, &txdata);
|
||||
control.Add(vChecks);
|
||||
control.Add(std::move(vChecks));
|
||||
}
|
||||
|
||||
bool controlCheck = control.Wait();
|
||||
|
@ -2324,7 +2324,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
||||
return error("ConnectBlock(): CheckInputScripts on %s failed with %s",
|
||||
tx.GetHash().ToString(), state.ToString());
|
||||
}
|
||||
control.Add(vChecks);
|
||||
control.Add(std::move(vChecks));
|
||||
}
|
||||
|
||||
CTxUndo undoDummy;
|
||||
|
Loading…
x
Reference in New Issue
Block a user