1 | // |
2 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
3 | // See https://llvm.org/LICENSE.txt for license information. |
4 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
5 | // |
6 | //===----------------------------------------------------------------------===// |
7 | |
8 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
9 | // UNSUPPORTED: no-threads |
10 | // XFAIL: availability-synchronization_library-missing |
11 | // XFAIL: !has-64-bit-atomics |
12 | // XFAIL: !has-1024-bit-atomics |
13 | |
14 | // void notify_one() const noexcept; |
15 | |
16 | #include <atomic> |
17 | #include <cassert> |
18 | #include <thread> |
19 | #include <type_traits> |
20 | #include <vector> |
21 | |
22 | #include "atomic_helpers.h" |
23 | #include "make_test_thread.h" |
24 | #include "test_macros.h" |
25 | |
26 | template <typename T> |
27 | struct TestNotifyOne { |
28 | void operator()() const { |
29 | T x(T(1)); |
30 | std::atomic_ref<T> const a(x); |
31 | |
32 | std::thread t = support::make_test_thread([&]() { |
33 | a.store(T(3)); |
34 | a.notify_one(); |
35 | }); |
36 | a.wait(T(1)); |
37 | assert(a.load() == T(3)); |
38 | t.join(); |
39 | ASSERT_NOEXCEPT(a.notify_one()); |
40 | } |
41 | }; |
42 | |
43 | int main(int, char**) { |
44 | TestEachAtomicType<TestNotifyOne>()(); |
45 | return 0; |
46 | } |
47 | |