Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / thread / thread.semaphore / release.pass.cpp
blobbf3dd7f7d814feb73adc63dcba73e345a6d42414
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
12 // XFAIL: availability-synchronization_library-missing
14 // <semaphore>
16 #include <semaphore>
17 #include <thread>
19 #include "make_test_thread.h"
20 #include "test_macros.h"
22 int main(int, char**)
24 std::counting_semaphore<> s(0);
26 s.release();
27 s.acquire();
29 std::thread t = support::make_test_thread([&](){
30 s.acquire();
31 });
32 s.release(2);
33 t.join();
34 s.acquire();
36 return 0;