brintos

brintos / llvm-project-archived public Read only

0
0
Text · 777 B · 029ce69 Raw
36 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// UNSUPPORTED: no-threads10// UNSUPPORTED: c++03, c++11, c++14, c++1711 12// <semaphore>13 14#include <semaphore>15#include <thread>16 17#include "make_test_thread.h"18#include "test_macros.h"19 20int main(int, char**)21{22  std::counting_semaphore<> s(0);23 24  s.release();25  s.acquire();26 27  std::thread t = support::make_test_thread([&](){28    s.acquire();29  });30  s.release(2);31  t.join();32  s.acquire();33 34  return 0;35}36