[lldb] Make SBProgress move-only (#124843)
[llvm-project.git] / libcxx / test / std / thread / thread.mutex / thread.lock / thread.lock.unique / thread.lock.unique.cons / mutex_time_point.pass.cpp
blob93d322050476f6279c771df54d9d562bd78aa24d
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 Clock, class Duration>
12 // unique_lock::unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
14 #include <cassert>
15 #include <chrono>
16 #include <mutex>
18 #include "checking_mutex.h"
20 int main(int, char**) {
21 checking_mutex mux;
23 { // check successful lock
24 mux.reject = false;
25 std::unique_lock<checking_mutex> lock(mux, std::chrono::time_point<std::chrono::system_clock>());
26 assert(mux.current_state == checking_mutex::locked_via_try_lock_until);
27 assert(lock.owns_lock());
29 assert(mux.current_state == checking_mutex::unlocked);
31 { // check unsuccessful lock
32 mux.reject = true;
33 std::unique_lock<checking_mutex> lock(mux, std::chrono::time_point<std::chrono::system_clock>());
34 assert(mux.current_state == checking_mutex::unlocked);
35 assert(mux.last_try == checking_mutex::locked_via_try_lock_until);
36 assert(!lock.owns_lock());
38 assert(mux.current_state == checking_mutex::unlocked);
40 return 0;