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
11 // UNSUPPORTED: c++03, c++98, c++11
15 // class shared_timed_mutex;
17 // void lock_shared();
19 #include <shared_mutex>
25 std::shared_timed_mutex m;
27 typedef std::chrono::system_clock Clock;
28 typedef Clock::time_point time_point;
29 typedef Clock::duration duration;
30 typedef std::chrono::milliseconds ms;
31 typedef std::chrono::nanoseconds ns;
35 time_point t0 = Clock::now();
37 time_point t1 = Clock::now();
39 ns d = t1 - t0 - ms(250);
40 assert(d < ms(50)); // within 50ms
45 time_point t0 = Clock::now();
47 time_point t1 = Clock::now();
50 assert(d < ms(50)); // within 50ms
57 std::vector<std::thread> v;
58 for (int i = 0; i < 5; ++i)
59 v.push_back(std::thread(f));
60 std::this_thread::sleep_for(ms(250));
68 std::this_thread::sleep_for(ms(250));