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 //===----------------------------------------------------------------------===//
8 //
9 // UNSUPPORTED: libcpp-has-no-threads
10 
11 // <thread>
12 
13 // template <class Clock, class Duration>
14 //   void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
15 
16 #include <thread>
17 #include <cstdlib>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 
main(int,char **)22 int main(int, char**)
23 {
24   typedef std::chrono::system_clock Clock;
25   typedef Clock::time_point time_point;
26   std::chrono::milliseconds ms(500);
27   time_point t0 = Clock::now();
28   std::this_thread::sleep_until(t0 + ms);
29   time_point t1 = Clock::now();
30   // NOTE: Operating systems are (by default) best effort and therefore we may
31   // have slept longer, perhaps much longer than we requested.
32   assert(t1 - t0 >= ms);
33 
34   return 0;
35 }
36