1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: libcpp-has-no-threads
10 // UNSUPPORTED: c++03, c++11
14 // shared_timed_mutex was introduced in macosx10.12
15 // UNSUPPORTED: with_system_cxx_lib=macosx10.11
16 // UNSUPPORTED: with_system_cxx_lib=macosx10.10
17 // UNSUPPORTED: with_system_cxx_lib=macosx10.9
21 // class shared_timed_mutex;
25 #include <shared_mutex>
30 #include "make_test_thread.h"
31 #include "test_macros.h"
33 std::shared_timed_mutex m
;
35 typedef std::chrono::system_clock Clock
;
36 typedef Clock::time_point time_point
;
37 typedef Clock::duration duration
;
38 typedef std::chrono::milliseconds ms
;
39 typedef std::chrono::nanoseconds ns
;
43 time_point t0
= Clock::now();
44 assert(!m
.try_lock());
45 assert(!m
.try_lock());
46 assert(!m
.try_lock());
49 time_point t1
= Clock::now();
51 ns d
= t1
- t0
- ms(250);
52 assert(d
< ms(200)); // within 200ms
58 std::thread t
= support::make_test_thread(f
);
59 std::this_thread::sleep_for(ms(250));