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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-threads
12 // <condition_variable>
14 // class condition_variable_any;
16 // template <class Lock, class Clock, class Duration>
18 // wait_until(Lock& lock, const chrono::time_point<Clock, Duration>& abs_time);
20 #include <condition_variable>
26 #include "make_test_thread.h"
27 #include "test_macros.h"
31 typedef std::chrono::milliseconds duration
;
32 typedef duration::rep rep
;
33 typedef duration::period period
;
34 typedef std::chrono::time_point
<Clock
> time_point
;
35 static const bool is_steady
= true;
37 static time_point
now()
39 using namespace std::chrono
;
40 return time_point(duration_cast
<duration
>(
41 steady_clock::now().time_since_epoch()
46 std::condition_variable_any cv
;
48 typedef std::timed_mutex L0
;
49 typedef std::unique_lock
<L0
> L1
;
64 Clock::time_point t0
= Clock::now();
65 Clock::time_point t
= t0
+ Clock::duration(250);
66 while (test2
== 0 && cv
.wait_until(lk
, t
) == std::cv_status::no_timeout
)
68 Clock::time_point t1
= Clock::now();
71 assert(t1
- t0
< Clock::duration(250));
76 assert(t1
- t0
- Clock::duration(250) < Clock::duration(50));
86 std::thread t
= support::make_test_thread(f
);
100 std::thread t
= support::make_test_thread(f
);