5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_SYNCHRONIZATION_LATCH_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_SYNCHRONIZATION_LATCH_HPP_
40 : count_(initial_count) {
61 auto try_wait() const noexcept ->
bool {
return count_.load(std::memory_order_acquire) == 0; }
72 if (count_.fetch_sub(update, std::memory_order_acq_rel) == update) {
109 std::atomic<std::ptrdiff_t> count_;
auto try_wait() const noexcept -> bool
Check if the latch is signalled without blocking.
Definition latch.hpp:61
void count_down()
Count down the latch by 1. If the counter reaches zero, the latch is permanently signalled,...
Definition latch.hpp:83
auto operator=(latch const &) -> latch &=delete
Not copyable.
latch(latch const &)=delete
Not copyable.
auto operator=(latch &&) -> latch &=delete
Not movable.
void arrive_and_wait()
Count down the latch by 1 and blocks the current thread waiting for the latch to be signalled.
Definition latch.hpp:105
static constexpr auto max() noexcept -> std::ptrdiff_t
Get the maximum supported count.
Definition latch.hpp:32
constexpr latch(std::ptrdiff_t initial_count)
Construct a latch with the specified count. If the count is zero, then the latch will be already sign...
Definition latch.hpp:39
~latch()=default
Default destructor.
void count_down(std::ptrdiff_t update)
Count down the latch by update. If the counter reaches zero, the latch is permanently signalled,...
Definition latch.hpp:70
void wait() const
Blocks the current thread until the latch becomes signalled.
Definition latch.hpp:87
void arrive_and_wait(std::ptrdiff_t const update)
Count down the latch by update and blocks the current thread waiting for the latch to be signalled.
Definition latch.hpp:97
latch(latch &&)=delete
Not movable.
An event class that allows blocking waits from an arbitrary number of threads that are then woken whe...
Definition manual_reset_event.hpp:38
static constexpr auto max() noexcept -> T
The maximum finite value.
Definition numeric_limits.hpp:230
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Public export header for the contracts subpackage.
Definition accumulate.hpp:37
::std::ptrdiff_t ptrdiff_t
The type of the difference between two pointers.
Definition builtin_types.hpp:27
Definition accumulate.hpp:36
::ptrdiff_t ptrdiff_t
A type suitable for holding the difference between two pointers.
Definition cstddef.hpp:31