class cpp20_latch
Declaration
class cpp20_latch { /* full declaration omitted */ };Description
Latches are a thread coordination mechanism that allow one or more threads to block until an operation is completed. An individual latch is a singleuse object; once the operation has been completed, the latch cannot be reused.
Declared at: libs/pika/synchronization/include/pika/synchronization/latch.hpp:30
Member Variables
- protected pika::concurrency::detail::cache_line_data< mutex_type> mtx_
- protected pika::concurrency::detail::cache_line_data< local::detail::condition_variable> cond_
- protected std::atomic<std::ptrdiff_t> counter_
- protected bool notified_
Method Overview
- public void arrive_and_wait(std::ptrdiff_t update = 1)
- public void count_down(std::ptrdiff_t update)
- public cpp20_latch(std::ptrdiff_t count)
- public static constexpr std::ptrdiff_t max() noexcept
- public bool try_wait() const noexcept
- public void wait() const
- public ~cpp20_latch()
Methods
void arrive_and_wait(std::ptrdiff_t update = 1)
void arrive_and_wait(std::ptrdiff_t update = 1)Description
Effects: Equivalent to: count_down(update); wait();
Declared at: libs/pika/synchronization/include/pika/synchronization/latch.hpp:141
Parameters
- std::ptrdiff_t update = 1
void count_down(std::ptrdiff_t update)
void count_down(std::ptrdiff_t update)Description
Decrements counter_ by n. Does not block. Requires: counter_ >= n and n >= 0. Synchronization: Synchronizes with all calls that block on this latch and with all try_wait calls on this latch that return true .
Declared at: libs/pika/synchronization/include/pika/synchronization/latch.hpp:88
Parameters
- std::ptrdiff_t update
cpp20_latch(std::ptrdiff_t count)
cpp20_latch(std::ptrdiff_t count)Description
Initialize the latch Requires: count >= 0. Synchronization: None Postconditions: counter_ == count.
Declared at: libs/pika/synchronization/include/pika/synchronization/latch.hpp:45
Parameters
- std::ptrdiff_t count
static constexpr std::ptrdiff_t max() noexcept
static constexpr std::ptrdiff_t max() noexceptDescription
Returns: The maximum value of counter that the implementation supports.
Declared at: libs/pika/synchronization/include/pika/synchronization/latch.hpp:74
bool try_wait() const noexcept
bool try_wait() const noexceptDescription
Returns: With very low probability false. Otherwise counter == 0.
Declared at: libs/pika/synchronization/include/pika/synchronization/latch.hpp:115
void wait() const
void wait() constDescription
If counter_ is 0, returns immediately. Otherwise, blocks the calling thread at the synchronization point until counter_ reaches 0.
Declared at: libs/pika/synchronization/include/pika/synchronization/latch.hpp:126
~cpp20_latch()
~cpp20_latch()Declared at: libs/pika/synchronization/include/pika/synchronization/latch.hpp:69