Changeset View
Changeset View
Standalone View
Standalone View
src/test/checkqueue_tests.cpp
Show First 20 Lines • Show All 361 Lines • ▼ Show 20 Lines | auto queue = std::make_unique<Standard_Queue>(QUEUE_BATCH_SIZE); | ||||
boost::thread_group tg; | boost::thread_group tg; | ||||
std::atomic<int> nThreads{0}; | std::atomic<int> nThreads{0}; | ||||
std::atomic<int> fails{0}; | std::atomic<int> fails{0}; | ||||
for (size_t i = 0; i < 3; ++i) { | for (size_t i = 0; i < 3; ++i) { | ||||
tg.create_thread([&] { | tg.create_thread([&] { | ||||
CCheckQueueControl<FakeCheck> control(queue.get()); | CCheckQueueControl<FakeCheck> control(queue.get()); | ||||
// While sleeping, no other thread should execute to this point | // While sleeping, no other thread should execute to this point | ||||
auto observed = ++nThreads; | auto observed = ++nThreads; | ||||
MilliSleep(10); | UninterruptibleSleep(std::chrono::milliseconds{10}); | ||||
fails += observed != nThreads; | fails += observed != nThreads; | ||||
}); | }); | ||||
} | } | ||||
tg.join_all(); | tg.join_all(); | ||||
BOOST_REQUIRE_EQUAL(fails, 0); | BOOST_REQUIRE_EQUAL(fails, 0); | ||||
} | } | ||||
{ | { | ||||
boost::thread_group tg; | boost::thread_group tg; | ||||
Show All 38 Lines |