Changeset View
Changeset View
Standalone View
Standalone View
src/test/scheduler_tests.cpp
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(schedule_every) { | ||||
CScheduler scheduler; | CScheduler scheduler; | ||||
boost::condition_variable cvar; | boost::condition_variable cvar; | ||||
std::atomic<int> counter{15}; | std::atomic<int> counter{15}; | ||||
std::atomic<bool> keepRunning{true}; | std::atomic<bool> keepRunning{true}; | ||||
scheduler.scheduleEvery( | scheduler.scheduleEvery( | ||||
[&keepRunning, &cvar, &counter, &scheduler]() { | [&keepRunning, &cvar, &counter, &scheduler]() { | ||||
BOOST_CHECK(counter > 0); | assert(counter > 0); | ||||
cvar.notify_all(); | cvar.notify_all(); | ||||
if (--counter > 0) { | if (--counter > 0) { | ||||
return true; | return true; | ||||
} | } | ||||
// We reached the end of our test, make sure nothing run again for | // We reached the end of our test, make sure nothing run again for | ||||
// 100ms. | // 100ms. | ||||
scheduler.scheduleFromNow( | scheduler.scheduleFromNow( | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |