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
11 // <condition_variable>
13 // class condition_variable_any;
17 #include <condition_variable>
24 #include "make_test_thread.h"
25 #include "test_macros.h"
27 std::condition_variable_any cv
;
29 typedef std::timed_mutex L0
;
30 typedef std::unique_lock
<L0
> L1
;
34 const unsigned threadCount
= 2;
35 bool pleaseExit
= false;
36 std::atomic
<unsigned> notReady
;
41 while (pleaseExit
== false)
47 notReady
= threadCount
;
48 std::vector
<std::thread
> threads(threadCount
);
49 for (unsigned i
= 0; i
< threadCount
; i
++)
50 threads
[i
] = support::make_test_thread(helper
);
53 std::this_thread::yield();
54 // At this point, both threads have had a chance to acquire the lock and are
55 // either waiting on the condition variable or about to wait.
58 // POSIX does not guarantee reliable scheduling if notify_all is called
59 // without the lock being held.
62 // The test will hang if not all of the threads were woken.
63 for (unsigned i
= 0; i
< threadCount
; i
++)