29 #ifndef _GLIBCXX_SEMAPHORE
30 #define _GLIBCXX_SEMAPHORE 1
32 #pragma GCC system_header
34 #if __cplusplus > 201703L
36 #if __cpp_lib_atomic_wait
39 namespace std _GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
43 #define __cpp_lib_semaphore 201907L
45 template<ptrdiff_t __least_max_value =
47 class counting_semaphore
49 static_assert(__least_max_value >= 0);
51 __semaphore_impl<__least_max_value> _M_sem;
54 explicit counting_semaphore(ptrdiff_t __desired) noexcept
58 ~counting_semaphore() =
default;
60 counting_semaphore(
const counting_semaphore&) =
delete;
61 counting_semaphore&
operator=(
const counting_semaphore&) =
delete;
63 static constexpr ptrdiff_t
65 {
return __least_max_value; }
68 release(ptrdiff_t __update = 1) noexcept(noexcept(_M_sem._M_release(1)))
69 { _M_sem._M_release(__update); }
72 acquire() noexcept(noexcept(_M_sem._M_acquire()))
73 { _M_sem._M_acquire(); }
76 try_acquire() noexcept(noexcept(_M_sem._M_try_acquire()))
77 {
return _M_sem._M_try_acquire(); }
79 template<
typename _Rep,
typename _Period>
82 {
return _M_sem._M_try_acquire_for(__rtime); }
84 template<
typename _Clock,
typename _Dur>
87 {
return _M_sem._M_try_acquire_until(__atime); }
90 using binary_semaphore = std::counting_semaphore<1>;
92 _GLIBCXX_END_NAMESPACE_VERSION
auto_ptr & operator=(auto_ptr &__a)
auto_ptr assignment operator.
element_type * release()
Bypassing the smart pointer.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.
__numeric_traits_integer< _Tp > __int_traits
Convenience alias for __numeric_traits<integer-type>.