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

Methods

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)

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)

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

Description

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

Description

Returns: With very low probability false. Otherwise counter == 0.

Declared at: libs/pika/synchronization/include/pika/synchronization/latch.hpp:115

void wait() const

Description

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()

Declared at: libs/pika/synchronization/include/pika/synchronization/latch.hpp:69