void f1() { t0 = Clock::now(); BOOST_TEST(m.try_lock_for(ms(750)) == true); t1 = Clock::now(); BOOST_TEST(m.try_lock()); m.unlock(); m.unlock(); }
void f() { #if defined BOOST_THREAD_USES_CHRONO time_point t0 = Clock::now(); BOOST_TEST(!m.try_lock()); BOOST_TEST(!m.try_lock()); BOOST_TEST(!m.try_lock()); while (!m.try_lock()) ; time_point t1 = Clock::now(); BOOST_TEST(m.try_lock()); m.unlock(); m.unlock(); ns d = t1 - t0 - ms(250); // This test is spurious as it depends on the time the thread system switches the threads BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms #else //time_point t0 = Clock::now(); //BOOST_TEST(!m.try_lock()); //BOOST_TEST(!m.try_lock()); //BOOST_TEST(!m.try_lock()); while (!m.try_lock()) ; //time_point t1 = Clock::now(); BOOST_TEST(m.try_lock()); m.unlock(); m.unlock(); //ns d = t1 - t0 - ms(250); // This test is spurious as it depends on the time the thread system switches the threads //BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms #endif }
void f1() { time_point t0 = Clock::now(); // This test is spurious as it depends on the time the thread system switches the threads BOOST_TEST(m.try_lock_for(ms(300)+ms(1000)) == true); time_point t1 = Clock::now(); BOOST_TEST(m.try_lock()); m.unlock(); m.unlock(); ns d = t1 - t0 - ms(250); // This test is spurious as it depends on the time the thread system switches the threads BOOST_TEST(d < ns(5000000)+ms(1000)); // within 5ms }