11#include "coopsync_tbb/detail/macros.hpp"
12#include "coopsync_tbb/detail/wait_queue.hpp"
20class COOPSYNC_TBB_EXPORT
latch {
26 explicit latch(std::ptrdiff_t expected);
48 static constexpr std::ptrdiff_t
max() noexcept;
53 COOPSYNC_TBB_NODISCARD
bool try_wait() const noexcept;
74 std::atomic<std::ptrdiff_t> m_counter;
75 detail::wait_queue m_waiters;
78inline constexpr std::ptrdiff_t
latch::
max() noexcept {
79 return std::numeric_limits<std::ptrdiff_t>::max();
latch(std::ptrdiff_t expected)
Constructs a latch with the specified initial count. The count must be non-negative.
void count_down(std::ptrdiff_t update=1)
Decrements the latch counter by the specified update. If the counter reaches zero,...
latch & operator=(const latch &)=delete
Latch is not copy-assignable.
latch & operator=(latch &&)=delete
Latch is not move-assignable.
void wait()
Suspends the calling task until the latch counter reaches zero. If the counter is already zero,...
bool try_wait() const noexcept
Checks if the latch has reached zero without suspending the calling task.
~latch()
Destroys the latch.
static constexpr std::ptrdiff_t max() noexcept
Returns the maximum value for the latch counter.
Definition latch.hpp:78
latch(const latch &)=delete
Latch is not copy-constructible.
latch(latch &&)=delete
Latch is not move-constructible.
void arrive_and_wait(std::ptrdiff_t update=1)
Decrements the latch counter by the specified update and suspends until the counter reaches zero....
Main namespace of the library, containing all public APIs.
Definition wait_for.hpp:11