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
13 // template <class Mutex> class unique_lock;
15 // mutex_type* release() noexcept;
20 #include "test_macros.h"
24 static int lock_count
;
25 static int unlock_count
;
26 void lock() {++lock_count
;}
27 void unlock() {++unlock_count
;}
30 int mutex::lock_count
= 0;
31 int mutex::unlock_count
= 0;
37 std::unique_lock
<mutex
> lk(m
);
38 assert(lk
.mutex() == &m
);
39 assert(lk
.owns_lock() == true);
40 assert(mutex::lock_count
== 1);
41 assert(mutex::unlock_count
== 0);
42 assert(lk
.release() == &m
);
43 assert(lk
.mutex() == nullptr);
44 assert(lk
.owns_lock() == false);
45 assert(mutex::lock_count
== 1);
46 assert(mutex::unlock_count
== 0);