61 assert(expected >= 0);
82 void arrive(ptrdiff_t n = 1) noexcept
84 assert(
counter.
load(std::memory_order_acquire) >= n);
85 assert(
counter.
load(std::memory_order_acquire) >= 0);
127 return counter.
load(std::memory_order_acquire) == 0;
149 while (
counter.
load(std::memory_order_acquire) > 0)
A single-use synchronisation point to coordinate concurrent threads.
Definition latch.hpp:36
latch & operator=(latch const &)=delete
Deleted.
latch(latch const &)=delete
Deleted.
std::atomic< std::ptrdiff_t > counter
The number of participating threads.
Definition latch.hpp:156
bool try_wait() const noexcept
Checks if all participating threads have reached the synchronisation point.
Definition latch.hpp:125
void wait() const
Waits for all participating threads to arrive at the synchronisation point.
Definition latch.hpp:145
latch(ptrdiff_t const expected)
Constructs the latch with the expected number of threads.
Definition latch.hpp:59
~latch()
Destructs the latch and waits for all participating threads to arrive.
Definition latch.hpp:49
std::atomic< std::ptrdiff_t > num_waiting
The number of waiting threads.
Definition latch.hpp:158
void arrive(ptrdiff_t n=1) noexcept
Atomically decrements counter by n.
Definition latch.hpp:82
void arrive_and_wait(ptrdiff_t n=1) noexcept
Atomically decrements counter by n and blocks the calling thread.
Definition latch.hpp:107
latch & operator=(latch &&)=delete
Deleted.
latch(latch &&)=delete
Deleted.
A delay for threads waiting for a shared resource.
Definition spin_delay.hpp:41
void wait()
Delays the calling thread by either using active spinning or passive spinning.
Definition spin_delay.hpp:62
constexpr std::size_t hardware_destructive_interference_size
Minimum offset between two objects to avoid false sharing.
Definition new:54
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
The <new> header from C++17's standard library.
Provides seqan3::detail::spin_delay.