15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier //
9*a7f9895cSLouis Dionne // UNSUPPORTED: no-threads
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // <thread>
125a83710eSEric Fiselier 
135a83710eSEric Fiselier // template <class Clock, class Duration>
145a83710eSEric Fiselier //   void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
155a83710eSEric Fiselier 
165a83710eSEric Fiselier #include <thread>
175a83710eSEric Fiselier #include <cstdlib>
185a83710eSEric Fiselier #include <cassert>
195a83710eSEric Fiselier 
207fc6a556SMarshall Clow #include "test_macros.h"
217fc6a556SMarshall Clow 
main(int,char **)222df59c50SJF Bastien int main(int, char**)
235a83710eSEric Fiselier {
245a83710eSEric Fiselier   typedef std::chrono::system_clock Clock;
255a83710eSEric Fiselier   typedef Clock::time_point time_point;
265a83710eSEric Fiselier   std::chrono::milliseconds ms(500);
275a83710eSEric Fiselier   time_point t0 = Clock::now();
285a83710eSEric Fiselier   std::this_thread::sleep_until(t0 + ms);
295a83710eSEric Fiselier   time_point t1 = Clock::now();
304f4d6c81SDavid Zarzycki   // NOTE: Operating systems are (by default) best effort and therefore we may
314f4d6c81SDavid Zarzycki   // have slept longer, perhaps much longer than we requested.
324f4d6c81SDavid Zarzycki   assert(t1 - t0 >= ms);
332df59c50SJF Bastien 
342df59c50SJF Bastien   return 0;
355a83710eSEric Fiselier }
36