46 lines · cpp
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-exception5//6//===----------------------------------------------------------------------===//7 8// UNSUPPORTED: c++03, c++11, c++14, c++179// UNSUPPORTED: no-threads10// XFAIL: !has-64-bit-atomics11// XFAIL: !has-1024-bit-atomics12 13// void notify_one() const noexcept;14 15#include <atomic>16#include <cassert>17#include <thread>18#include <type_traits>19#include <vector>20 21#include "atomic_helpers.h"22#include "make_test_thread.h"23#include "test_macros.h"24 25template <typename T>26struct TestNotifyOne {27 void operator()() const {28 T x(T(1));29 std::atomic_ref<T> const a(x);30 31 std::thread t = support::make_test_thread([&]() {32 a.store(T(3));33 a.notify_one();34 });35 a.wait(T(1));36 assert(a.load() == T(3));37 t.join();38 ASSERT_NOEXCEPT(a.notify_one());39 }40};41 42int main(int, char**) {43 TestEachAtomicType<TestNotifyOne>()();44 return 0;45}46