]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/thread/test/sync/mutual_exclusion/recursive_timed_mutex/try_lock_for_pass.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / thread / test / sync / mutual_exclusion / recursive_timed_mutex / try_lock_for_pass.cpp
index bcbd53905fa254443792d77bb14d63805cb7b757..2b428e8c4bbfb6fe9e639afb90a81eb5ce1bec81 100644 (file)
@@ -34,18 +34,22 @@ 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_TEST(m.try_lock_for(ms(300)+ms(1000)) == true);
+  BOOST_TEST(m.try_lock_for(ms(750)) == 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
+  BOOST_TEST(d < max_diff);
 }
 
 void f2()
@@ -54,8 +58,7 @@ void f2()
   BOOST_TEST(m.try_lock_for(ms(250)) == 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()
@@ -70,7 +73,7 @@ int main()
   {
     m.lock();
     boost::thread t(f2);
-    boost::this_thread::sleep_for(ms(400));
+    boost::this_thread::sleep_for(ms(750));
     m.unlock();
     t.join();
   }