int runs = 0;
+#ifdef BOOST_THREAD_PLATFORM_WIN32
+const Clock::duration max_diff(250);
+#else
+const Clock::duration max_diff(75);
+#endif
+
void f()
{
L1 lk(m0);
cv.notify_one();
Clock::time_point t0 = Clock::now();
Clock::time_point t = t0 + Clock::duration(250);
- int count=0;
- while (test2 == 0 && cv.wait_until(lk, t) == boost::cv_status::no_timeout)
- count++;
+ while (test2 == 0 && cv.wait_until(lk, t) == boost::cv_status::no_timeout) {}
Clock::time_point t1 = Clock::now();
if (runs == 0)
{
- BOOST_TEST(t1 - t0 < Clock::duration(250));
+ BOOST_TEST(t1 - t0 < max_diff);
BOOST_TEST(test2 != 0);
}
else
{
- // This test is spurious as it depends on the time the thread system switches the threads
- BOOST_TEST(t1 - t0 - Clock::duration(250) < Clock::duration(250*count+5+1000));
+ BOOST_TEST(t1 - t0 - Clock::duration(250) < max_diff);
BOOST_TEST(test2 == 0);
}
++runs;