Changeset View
Changeset View
Standalone View
Standalone View
src/test/scheduler_tests.cpp
Show All 27 Lines | if (rescheduleTime != noTime) { | ||||
CScheduler::Function f = | CScheduler::Function f = | ||||
boost::bind(µTask, std::ref(s), std::ref(mutex), | boost::bind(µTask, std::ref(s), std::ref(mutex), | ||||
std::ref(counter), -delta + 1, noTime); | std::ref(counter), -delta + 1, noTime); | ||||
s.schedule(f, rescheduleTime); | s.schedule(f, rescheduleTime); | ||||
} | } | ||||
} | } | ||||
static void MicroSleep(uint64_t n) { | static void MicroSleep(uint64_t n) { | ||||
#if defined(HAVE_WORKING_BOOST_SLEEP_FOR) | |||||
boost::this_thread::sleep_for(boost::chrono::microseconds(n)); | boost::this_thread::sleep_for(boost::chrono::microseconds(n)); | ||||
#elif defined(HAVE_WORKING_BOOST_SLEEP) | |||||
boost::this_thread::sleep(boost::posix_time::microseconds(n)); | |||||
#else | |||||
// should never get here | |||||
#error missing boost sleep implementation | |||||
#endif | |||||
} | } | ||||
BOOST_AUTO_TEST_CASE(manythreads) { | BOOST_AUTO_TEST_CASE(manythreads) { | ||||
// Stress test: hundreds of microsecond-scheduled tasks, | // Stress test: hundreds of microsecond-scheduled tasks, | ||||
// serviced by 10 threads. | // serviced by 10 threads. | ||||
// | // | ||||
// So... ten shared counters, which if all the tasks execute | // So... ten shared counters, which if all the tasks execute | ||||
// properly will sum to the number of tasks done. | // properly will sum to the number of tasks done. | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |