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: no-threads
10 // UNSUPPORTED: c++03, c++11
14 // class shared_timed_mutex;
18 #include <shared_mutex>
24 #include "make_test_thread.h"
26 int main(int, char**) {
27 // Try to exclusive-lock a mutex that is not locked yet. This should succeed.
29 std::shared_timed_mutex m
;
30 bool succeeded
= m
.try_lock();
35 // Try to exclusive-lock a mutex that is already locked exclusively. This should fail.
37 std::shared_timed_mutex m
;
40 std::thread t
= support::make_test_thread([&] {
41 bool succeeded
= m
.try_lock();
49 // Try to exclusive-lock a mutex that is already share-locked. This should fail.
51 std::shared_timed_mutex m
;
54 std::thread t
= support::make_test_thread([&] {
55 bool succeeded
= m
.try_lock();