1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// UNSUPPORTED: libcpp-has-no-threads
11
12// <mutex>
13
14// template <class Mutex> class unique_lock;
15
16// mutex_type* release() noexcept;
17
18#include <mutex>
19#include <cassert>
20
21struct mutex
22{
23    static int lock_count;
24    static int unlock_count;
25    void lock() {++lock_count;}
26    void unlock() {++unlock_count;}
27};
28
29int mutex::lock_count = 0;
30int mutex::unlock_count = 0;
31
32mutex m;
33
34int main()
35{
36    std::unique_lock<mutex> lk(m);
37    assert(lk.mutex() == &m);
38    assert(lk.owns_lock() == true);
39    assert(mutex::lock_count == 1);
40    assert(mutex::unlock_count == 0);
41    assert(lk.release() == &m);
42    assert(lk.mutex() == nullptr);
43    assert(lk.owns_lock() == false);
44    assert(mutex::lock_count == 1);
45    assert(mutex::unlock_count == 0);
46}
47