Changeset View
Changeset View
Standalone View
Standalone View
src/test/scheduler_tests.cpp
Show First 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(singlethreadedscheduler_ordered) { | ||||
// required here | // required here | ||||
int counter1 = 0; | int counter1 = 0; | ||||
int counter2 = 0; | int counter2 = 0; | ||||
// just simply count up on each queue - if execution is properly ordered | // just simply count up on each queue - if execution is properly ordered | ||||
// then the callbacks should run in exactly the order in which they were | // then the callbacks should run in exactly the order in which they were | ||||
// enqueued | // enqueued | ||||
for (int i = 0; i < 100; ++i) { | for (int i = 0; i < 100; ++i) { | ||||
queue1.AddToProcessQueue( | queue1.AddToProcessQueue([i, &counter1]() { assert(i == counter1++); }); | ||||
[i, &counter1]() { BOOST_CHECK_EQUAL(i, counter1++); }); | |||||
queue2.AddToProcessQueue( | queue2.AddToProcessQueue([i, &counter2]() { assert(i == counter2++); }); | ||||
[i, &counter2]() { BOOST_CHECK_EQUAL(i, counter2++); }); | |||||
} | } | ||||
// finish up | // finish up | ||||
scheduler.stop(true); | scheduler.stop(true); | ||||
threads.join_all(); | threads.join_all(); | ||||
BOOST_CHECK_EQUAL(counter1, 100); | BOOST_CHECK_EQUAL(counter1, 100); | ||||
BOOST_CHECK_EQUAL(counter2, 100); | BOOST_CHECK_EQUAL(counter2, 100); | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |