]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/thread/test/sync/mutual_exclusion/locks/unique_lock/cons/time_point_pass.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / thread / test / sync / mutual_exclusion / locks / unique_lock / cons / time_point_pass.cpp
index e9f821ab193c98a76b2ef7907b42aab7a7c8c182..73c501827791d6a15d07db2c846e66135f232977 100644 (file)
@@ -36,16 +36,20 @@ typedef Clock::duration duration;
 typedef boost::chrono::milliseconds ms;
 typedef boost::chrono::nanoseconds ns;
 
+#ifdef BOOST_THREAD_PLATFORM_WIN32
+const ms max_diff(250);
+#else
+const ms max_diff(75);
+#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::unique_lock<boost::timed_mutex> lk(m, Clock::now() + ms(300)+ms(1000));
+  boost::unique_lock<boost::timed_mutex> lk(m, Clock::now() + ms(750));
   BOOST_TEST(lk.owns_lock() == true);
   time_point t1 = Clock::now();
-  // This test is spurious as it depends on the time the thread system switches the threads
   ns d = t1 - t0 - ms(250);
-  BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
+  BOOST_TEST(d < max_diff);
 }
 
 void f2()
@@ -55,8 +59,7 @@ void f2()
   BOOST_TEST(lk.owns_lock() == false);
   time_point t1 = Clock::now();
   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
+  BOOST_TEST(d < max_diff);
 }
 
 int main()
@@ -71,7 +74,7 @@ int main()
   {
     m.lock();
     boost::thread t(f2);
-    boost::this_thread::sleep_for(ms(350));
+    boost::this_thread::sleep_for(ms(750));
     m.unlock();
     t.join();
   }