1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: libcpp-has-no-threads
14 // template <class Mutex> class lock_guard;
16 // explicit lock_guard(mutex_type& m);
18 // template<class _Mutex> lock_guard(lock_guard<_Mutex>)
19 // -> lock_guard<_Mutex>; // C++17
26 #include "test_macros.h"
30 typedef std::chrono::system_clock Clock;
31 typedef Clock::time_point time_point;
32 typedef Clock::duration duration;
33 typedef std::chrono::milliseconds ms;
34 typedef std::chrono::nanoseconds ns;
38 time_point t0 = Clock::now();
41 std::lock_guard<std::mutex> lg(m);
44 ns d = t1 - t0 - ms(250);
45 assert(d < ms(200)); // within 200ms
52 std::this_thread::sleep_for(ms(250));
56 #ifdef __cpp_deduction_guides
57 std::lock_guard lg(m);
58 static_assert((std::is_same<decltype(lg), std::lock_guard<decltype(m)>>::value), "" );