class latch

Declaration

class latch : public cpp20_latch { /* full declaration omitted */ };

Description

//////////////////////////////////////////////////////////////////////// A latch maintains an internal counter_ that is initialized when the latch is created. Threads may block at a synchronization point waiting for counter_ to be decremented to 0. When counter_ reaches 0, all such blocked threads are released. Calls to countdown_and_wait() , count_down() , wait() , is_ready(), count_up() , and reset() behave as atomic operations.

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

Inherits from: cpp20_latch

Member Variables

Inherited from cpp20_latch:

protected mtx_
protected cond_
protected counter_
protected notified_

Method Overview

Inherited from cpp20_latch:

Methods

void abort_all()

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

void count_down_and_wait()

Description

Decrements counter_ by 1 . Blocks at the synchronization point until counter_ reaches 0. Requires: counter_ > 0. Synchronization: Synchronizes with all calls that block on this latch and with all is_ready calls on this latch that return true.

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

void count_up(std::ptrdiff_t n)

Description

Increments counter_ by n. Does not block. Requires: n >= 0.

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

Parameters

std::ptrdiff_t n

bool is_ready() const noexcept

Description

Returns: counter_ == 0. Does not block.

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

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:210

Parameters

std::ptrdiff_t count

void reset(std::ptrdiff_t n)

Description

Reset counter_ to n. Does not block. Requires: n >= 0.

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

Parameters

std::ptrdiff_t n

bool reset_if_needed_and_count_up(
    std::ptrdiff_t n,
    std::ptrdiff_t count)

Description

Effects: Equivalent to: if (is_ready()) reset(count); count_up(n); Returns: true if the latch was reset

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

Parameters

std::ptrdiff_t n
std::ptrdiff_t count

~latch()

Description

Requires: No threads are blocked at the synchronization point.

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