Changeset View
Changeset View
Standalone View
Standalone View
src/test/checkqueue_tests.cpp
Show First 20 Lines • Show All 323 Lines • ▼ Show 20 Lines | std::thread t0([&]() { | ||||
CCheckQueueControl<FrozenCleanupCheck> control(queue.get()); | CCheckQueueControl<FrozenCleanupCheck> control(queue.get()); | ||||
std::vector<FrozenCleanupCheck> vChecks(1); | std::vector<FrozenCleanupCheck> vChecks(1); | ||||
// Freezing can't be the default initialized behavior given how the | // Freezing can't be the default initialized behavior given how the | ||||
// queue | // queue | ||||
// swaps in default initialized Checks (otherwise freezing destructor | // swaps in default initialized Checks (otherwise freezing destructor | ||||
// would get called twice). | // would get called twice). | ||||
vChecks[0].should_freeze = true; | vChecks[0].should_freeze = true; | ||||
control.Add(vChecks); | control.Add(vChecks); | ||||
control.Wait(); // Hangs here | // Hangs here | ||||
bool waitResult = control.Wait(); | |||||
assert(waitResult); | |||||
}); | }); | ||||
{ | { | ||||
std::unique_lock<std::mutex> l(FrozenCleanupCheck::m); | std::unique_lock<std::mutex> l(FrozenCleanupCheck::m); | ||||
// Wait until the queue has finished all jobs and frozen | // Wait until the queue has finished all jobs and frozen | ||||
FrozenCleanupCheck::cv.wait( | FrozenCleanupCheck::cv.wait( | ||||
l, []() { return FrozenCleanupCheck::nFrozen == 1; }); | l, []() { return FrozenCleanupCheck::nFrozen == 1; }); | ||||
} | } | ||||
// Try to get control of the queue a bunch of times | // Try to get control of the queue a bunch of times | ||||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |