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:
parent
0682003214
commit
6c2d5972f3
3 changed files with 14 additions and 5 deletions
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct DumbCheck {
|
struct DumbCheck {
|
||||||
const bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
DumbCheck() = default;
|
DumbCheck() = default;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue