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
10// UNSUPPORTED: c++03, c++11, c++14, c++17
11
12// XFAIL: availability-synchronization_library-missing
13
14// <barrier>
15
16#include <barrier>
17#include <thread>
18
19#include "make_test_thread.h"
20#include "test_macros.h"
21
22int main(int, char**)
23{
24 std::barrier<> b(2);
25
26 std::thread t = support::make_test_thread([&](){
27 for(int i = 0; i < 10; ++i)
28 b.arrive_and_wait();
29 });
30 for(int i = 0; i < 10; ++i)
31 b.arrive_and_wait();
32 t.join();
33
34 return 0;
35}
36

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of libcxx/test/std/thread/thread.barrier/arrive_and_wait.pass.cpp