63 explicit latch(ptrdiff_t
const expected) :
66 assert(expected >= 0);
87 void arrive(ptrdiff_t n = 1) noexcept
89 assert(
counter.
load(std::memory_order_acquire) >= n);
90 assert(
counter.
load(std::memory_order_acquire) >= 0);
132 return counter.
load(std::memory_order_acquire) == 0;
154 while (
counter.
load(std::memory_order_acquire) > 0)
A single-use synchronisation point to coordinate concurrent threads.
Definition: latch.hpp:39
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:162
bool try_wait() const noexcept
Checks if all participating threads have reached the synchronisation point.
Definition: latch.hpp:130
void wait() const
Waits for all participating threads to arrive at the synchronisation point.
Definition: latch.hpp:150
latch(ptrdiff_t const expected)
Constructs the latch with the expected number of threads.
Definition: latch.hpp:63
~latch()
Destructs the latch and waits for all participating threads to arrive.
Definition: latch.hpp:53
std::atomic< std::ptrdiff_t > num_waiting
The number of waiting threads.
Definition: latch.hpp:164
void arrive(ptrdiff_t n=1) noexcept
Atomically decrements counter by n.
Definition: latch.hpp:87
void arrive_and_wait(ptrdiff_t n=1) noexcept
Atomically decrements counter by n and blocks the calling thread.
Definition: latch.hpp:112
latch & operator=(latch &&)=delete
Deleted.
latch(latch &&)=delete
Deleted.
A delay for threads waiting for a shared resource.
Definition: spin_delay.hpp:42
void wait()
Delays the calling thread by either using active spinning or passive spinning.
Definition: spin_delay.hpp:63
constexpr std::size_t hardware_destructive_interference_size
Minimum offset between two objects to avoid false sharing.
Definition: new:32
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
The <new> header from C++17's standard library.
Provides seqan3::detail::spin_delay.