test: Default initialize should_freeze to true

It is safe now, when move semantics is used instead of a custom swap
function.
This commit is contained in:
Hennadii Stepanov 2023-03-21 13:05:00 +00:00
parent cea50521fe
commit 95ad70ab65
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F

View File

@ -109,9 +109,7 @@ struct FrozenCleanupCheck {
static std::atomic<uint64_t> nFrozen;
static std::condition_variable cv;
static std::mutex m;
// Freezing can't be the default initialized behavior given how the queue
// swaps in default initialized Checks.
bool should_freeze {false};
bool should_freeze{true};
bool operator()() const
{
return true;
@ -344,10 +342,6 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup)
std::thread t0([&]() {
CCheckQueueControl<FrozenCleanupCheck> control(queue.get());
std::vector<FrozenCleanupCheck> vChecks(1);
// Freezing can't be the default initialized behavior given how the queue
// swaps in default initialized Checks (otherwise freezing destructor
// would get called twice).
vChecks[0].should_freeze = true;
control.Add(std::move(vChecks));
bool waitResult = control.Wait(); // Hangs here
assert(waitResult);