29#ifndef _GLIBCXX_SEMAPHORE
30#define _GLIBCXX_SEMAPHORE 1
32#pragma GCC system_header
36#if __cplusplus > 201703L
39#if __cpp_lib_atomic_wait || _GLIBCXX_HAVE_POSIX_SEMAPHORE
40namespace std _GLIBCXX_VISIBILITY(default)
42_GLIBCXX_BEGIN_NAMESPACE_VERSION
44#define __cpp_lib_semaphore 201907L
46 template<ptrdiff_t __least_max_value = __semaphore_impl::_S_max>
47 class counting_semaphore
49 static_assert(__least_max_value >= 0);
50 static_assert(__least_max_value <= __semaphore_impl::_S_max);
52 __semaphore_impl _M_sem;
55 explicit counting_semaphore(ptrdiff_t __desired) noexcept
59 ~counting_semaphore() =
default;
61 counting_semaphore(
const counting_semaphore&) =
delete;
62 counting_semaphore& operator=(
const counting_semaphore&) =
delete;
64 static constexpr ptrdiff_t
66 {
return __least_max_value; }
69 release(ptrdiff_t __update = 1) noexcept(noexcept(_M_sem._M_release(1)))
70 { _M_sem._M_release(__update); }
73 acquire() noexcept(noexcept(_M_sem._M_acquire()))
74 { _M_sem._M_acquire(); }
77 try_acquire() noexcept(noexcept(_M_sem._M_try_acquire()))
78 {
return _M_sem._M_try_acquire(); }
80 template<
typename _Rep,
typename _Period>
83 {
return _M_sem._M_try_acquire_for(__rtime); }
85 template<
typename _Clock,
typename _Dur>
88 {
return _M_sem._M_try_acquire_until(__atime); }
91 using binary_semaphore = std::counting_semaphore<1>;
93_GLIBCXX_END_NAMESPACE_VERSION
ISO C++ entities toplevel namespace is std.
chrono::duration represents a distance between two points in time
chrono::time_point represents a point in time as measured by a clock