[Xtensa] Move XtensaUtils to MCTargetDesc
[llvm-project.git] / libcxx / test / std / thread / thread.mutex / thread.lock / thread.lock.unique / thread.lock.unique.mod / release.pass.cpp
bloba7724504a667c188cc59a6d42473cf10724440f8
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <mutex>
11 // template <class Mutex> class unique_lock;
13 // mutex_type* release() noexcept;
15 #include <cassert>
16 #include <memory>
17 #include <mutex>
19 #include "checking_mutex.h"
20 #include "test_macros.h"
22 #if TEST_STD_VER >= 11
23 static_assert(noexcept(std::declval<std::unique_lock<checking_mutex>&>().release()), "");
24 #endif
26 int main(int, char**) {
27 checking_mutex mux;
28 std::unique_lock<checking_mutex> lock(mux);
29 assert(lock.mutex() == std::addressof(mux));
30 assert(lock.owns_lock());
32 assert(mux.current_state == checking_mutex::locked_via_lock);
34 assert(lock.release() == std::addressof(mux));
35 assert(lock.mutex() == nullptr);
36 assert(!lock.owns_lock());
37 assert(mux.last_try == checking_mutex::locked_via_lock);
38 assert(mux.current_state == checking_mutex::locked_via_lock);
39 mux.unlock();
41 return 0;