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 //===----------------------------------------------------------------------===//
11 // template <class Clock, class Duration>
12 // unique_lock::unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
18 #include "checking_mutex.h"
20 int main(int, char**) {
23 { // check successful lock
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
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
);