[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / thread / thread.condition / thread.condition.condvarany / wait.pass.cpp
blobffce91be0e59fb6ade86be24b3e9468f1cf8dba2
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: no-threads
11 // <condition_variable>
13 // class condition_variable_any;
15 // template <class Lock>
16 // void wait(Lock& lock);
18 #include <condition_variable>
19 #include <mutex>
20 #include <thread>
21 #include <cassert>
23 #include "make_test_thread.h"
24 #include "test_macros.h"
26 std::condition_variable_any cv;
28 typedef std::timed_mutex L0;
29 typedef std::unique_lock<L0> L1;
31 L0 m0;
33 int test1 = 0;
34 int test2 = 0;
36 void f()
38 L1 lk(m0);
39 assert(test2 == 0);
40 test1 = 1;
41 cv.notify_one();
42 while (test2 == 0)
43 cv.wait(lk);
44 assert(test2 != 0);
47 int main(int, char**)
49 L1 lk(m0);
50 std::thread t = support::make_test_thread(f);
51 assert(test1 == 0);
52 while (test1 == 0)
53 cv.wait(lk);
54 assert(test1 != 0);
55 test2 = 1;
56 lk.unlock();
57 cv.notify_one();
58 t.join();
60 return 0;