Provide a single‐use thread synchronization mechanism on an event count.

Synopsis

Declared in <bslmt_latch.h>

class Latch;

Description

This class defines a thread synchronization mechanism that allows one or more threads to wait until a certain number of operations have been performed by other threads.

Enums

Name

Description

Unnamed enum

Status codes for timed wait operations.

Member Functions

Name

Description

Latch [constructor]

Constructors

~Latch [destructor]

Destroy this latch. The behavior is undefined if any threads are waiting on this latch.

arrive

Decrement the event count by 1 and release waiters if it reaches 0.

arriveAndWait

Decrement the event count by 1, then wait until the latch is released.

clockType

Return the clock type used for timeouts.

countDown

Decrement the event count by numEvents and release waiters if 0.

currentCount

Return the current number of events for which this latch is waiting.

timedWait

Block until this latch is released or absTime expires.

tryWait

Return whether this latch has already been released.

wait

Block until the number of events this latch waits for reaches 0.

Created with MrDocs