diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp index e42c16b31fcb..fcd883743eba 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp @@ -8,8 +8,6 @@ // // UNSUPPORTED: libcpp-has-no-threads -// ALLOW_RETRIES: 2 - // // template class lock_guard; @@ -17,7 +15,6 @@ // lock_guard(mutex_type& m, adopt_lock_t); #include -#include #include #include @@ -25,32 +22,16 @@ std::mutex m; -typedef std::chrono::system_clock Clock; -typedef Clock::time_point time_point; -typedef Clock::duration duration; -typedef std::chrono::milliseconds ms; -typedef std::chrono::nanoseconds ns; - -void f() +int main() { - time_point t0 = Clock::now(); - time_point t1; - { + { m.lock(); std::lock_guard lg(m, std::adopt_lock); - t1 = Clock::now(); - } - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms -} + assert(m.try_lock() == false); + } -int main(int, char**) -{ - m.lock(); - std::thread t(f); - std::this_thread::sleep_for(ms(250)); - m.unlock(); - t.join(); + m.lock(); + m.unlock(); return 0; } diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp index fc2230591aea..71a72ffd050e 100644 --- a/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp @@ -8,8 +8,6 @@ // // UNSUPPORTED: libcpp-has-no-threads -// ALLOW_RETRIES: 2 - // // template class lock_guard; @@ -20,7 +18,6 @@ // -> lock_guard<_Mutex>; // C++17 #include -#include #include #include @@ -28,35 +25,19 @@ std::mutex m; -typedef std::chrono::system_clock Clock; -typedef Clock::time_point time_point; -typedef Clock::duration duration; -typedef std::chrono::milliseconds ms; -typedef std::chrono::nanoseconds ns; - -void f() +int main() { - time_point t0 = Clock::now(); - time_point t1; - { + { std::lock_guard lg(m); - t1 = Clock::now(); - } - ns d = t1 - t0 - ms(250); - assert(d < ms(200)); // within 200ms -} + assert(m.try_lock() == false); + } -int main(int, char**) -{ - m.lock(); - std::thread t(f); - std::this_thread::sleep_for(ms(250)); - m.unlock(); - t.join(); + m.lock(); + m.unlock(); #ifdef __cpp_deduction_guides - std::lock_guard lg(m); - static_assert((std::is_same>::value), "" ); + std::lock_guard lg(m); + static_assert((std::is_same>::value), "" ); #endif return 0;