xref: /aosp_15_r20/external/cronet/third_party/libc++/src/test/std/thread/thread.semaphore/acquire.pass.cpp (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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
11 
12 // XFAIL: availability-synchronization_library-missing
13 
14 // <semaphore>
15 
16 #include <semaphore>
17 #include <thread>
18 
19 #include "make_test_thread.h"
20 #include "test_macros.h"
21 
main(int,char **)22 int main(int, char**)
23 {
24   std::counting_semaphore<> s(2);
25 
26   std::thread t = support::make_test_thread([&](){
27     s.acquire();
28   });
29   t.join();
30 
31   s.acquire();
32 
33   return 0;
34 }
35