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// <mutex>
11
12// template <class Mutex> class unique_lock;
13
14// mutex_type* release() noexcept;
15
16#include <mutex>
17#include <cassert>
18
19struct mutex
20{
21    static int lock_count;
22    static int unlock_count;
23    void lock() {++lock_count;}
24    void unlock() {++unlock_count;}
25};
26
27int mutex::lock_count = 0;
28int mutex::unlock_count = 0;
29
30mutex m;
31
32int main()
33{
34    std::unique_lock<mutex> lk(m);
35    assert(lk.mutex() == &m);
36    assert(lk.owns_lock() == true);
37    assert(mutex::lock_count == 1);
38    assert(mutex::unlock_count == 0);
39    assert(lk.release() == &m);
40    assert(lk.mutex() == nullptr);
41    assert(lk.owns_lock() == false);
42    assert(mutex::lock_count == 1);
43    assert(mutex::unlock_count == 0);
44}
45