0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

refactor: Use move semantics in CCheckQueue::Add

Co-authored-by: Martin Leitner-Ankerl <martin.ankerl@gmail.com>
This commit is contained in:
Hennadii Stepanov 2023-03-21 13:03:41 +00:00
parent 0682003214
commit 6c2d5972f3
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
3 changed files with 14 additions and 5 deletions

View file

@ -11,6 +11,7 @@
#include <util/threadnames.h> #include <util/threadnames.h>
#include <algorithm> #include <algorithm>
#include <iterator>
#include <vector> #include <vector>
template <typename T> template <typename T>
@ -173,10 +174,7 @@ public:
{ {
LOCK(m_mutex); LOCK(m_mutex);
for (T& check : vChecks) { queue.insert(queue.end(), std::make_move_iterator(vChecks.begin()), std::make_move_iterator(vChecks.end()));
queue.emplace_back();
check.swap(queue.back());
}
nTodo += vChecks.size(); nTodo += vChecks.size();
} }

View file

@ -140,6 +140,17 @@ struct FrozenCleanupCheck {
cv.wait(l, []{ return nFrozen.load(std::memory_order_relaxed) == 0;}); cv.wait(l, []{ return nFrozen.load(std::memory_order_relaxed) == 0;});
} }
} }
FrozenCleanupCheck(FrozenCleanupCheck&& other) noexcept
{
should_freeze = other.should_freeze;
other.should_freeze = false;
}
FrozenCleanupCheck& operator=(FrozenCleanupCheck&& other) noexcept
{
should_freeze = other.should_freeze;
other.should_freeze = false;
return *this;
}
void swap(FrozenCleanupCheck& x) noexcept void swap(FrozenCleanupCheck& x) noexcept
{ {
std::swap(should_freeze, x.should_freeze); std::swap(should_freeze, x.should_freeze);

View file

@ -13,7 +13,7 @@
namespace { namespace {
struct DumbCheck { struct DumbCheck {
const bool result = false; bool result = false;
DumbCheck() = default; DumbCheck() = default;