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
10 // UNSUPPORTED: c++03, c++11, c++14, c++17
12 // XFAIL: availability-synchronization_library-missing
20 #include "make_test_thread.h"
21 #include "test_macros.h"
25 std::counting_semaphore
<> s(1);
27 assert(s
.try_acquire());
28 assert(!s
.try_acquire());
30 assert(s
.try_acquire());
31 assert(!s
.try_acquire());
33 std::thread t
= support::make_test_thread([&](){
34 assert(s
.try_acquire());
37 assert(s
.try_acquire());
38 assert(!s
.try_acquire());