29 #ifndef _GLIBCXX_SEMAPHORE 30 #define _GLIBCXX_SEMAPHORE 1 32 #pragma GCC system_header 34 #if __cplusplus > 201703L 37 #if __cpp_lib_atomic_wait || _GLIBCXX_HAVE_POSIX_SEMAPHORE 38 namespace std _GLIBCXX_VISIBILITY(default)
40 _GLIBCXX_BEGIN_NAMESPACE_VERSION
42 #define __cpp_lib_semaphore 201907L 44 template<ptrdiff_t __least_max_value = __semaphore_impl::_S_max>
45 class counting_semaphore
47 static_assert(__least_max_value >= 0);
48 static_assert(__least_max_value <= __semaphore_impl::_S_max);
50 __semaphore_impl _M_sem;
53 explicit counting_semaphore(ptrdiff_t __desired) noexcept
57 ~counting_semaphore() =
default;
59 counting_semaphore(
const counting_semaphore&) =
delete;
60 counting_semaphore& operator=(
const counting_semaphore&) =
delete;
62 static constexpr ptrdiff_t
64 {
return __least_max_value; }
67 release(ptrdiff_t __update = 1) noexcept(noexcept(_M_sem._M_release(1)))
68 { _M_sem._M_release(__update); }
71 acquire() noexcept(noexcept(_M_sem._M_acquire()))
72 { _M_sem._M_acquire(); }
75 try_acquire() noexcept(noexcept(_M_sem._M_try_acquire()))
76 {
return _M_sem._M_try_acquire(); }
78 template<
typename _Rep,
typename _Period>
81 {
return _M_sem._M_try_acquire_for(__rtime); }
83 template<
typename _Clock,
typename _Dur>
86 {
return _M_sem._M_try_acquire_until(__atime); }
89 using binary_semaphore = std::counting_semaphore<1>;
91 _GLIBCXX_END_NAMESPACE_VERSION
93 #endif // cpp_lib_atomic_wait || _GLIBCXX_HAVE_POSIX_SEMAPHORE 95 #endif // _GLIBCXX_SEMAPHORE
chrono::duration represents a distance between two points in time
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
chrono::time_point represents a point in time as measured by a clock
ISO C++ entities toplevel namespace is std.