9#ifndef CPPCOMMON_THREADS_LATCH_H
10#define CPPCOMMON_THREADS_LATCH_H
15#include <condition_variable>
44 int threads() const noexcept {
return _threads; }
111 std::condition_variable _cond;
115 bool CountDown(std::unique_lock<std::mutex>& lock) noexcept;
Latch synchronization primitive.
void Reset(int threads) noexcept
Reset the latch with a new threads counter value.
int threads() const noexcept
Get the count of threads to wait for the latch.
Latch & operator=(const Latch &)=delete
bool TryWaitUntil(const Timestamp ×tamp) noexcept
Try to wait for the latch until the given timestamp.
bool TryWait() noexcept
Try to wait for the latch without block.
void CountDown() noexcept
Countdown the latch.
Latch & operator=(Latch &&)=delete
bool TryWaitFor(const Timespan ×pan) noexcept
Try to wait for the latch for the given timespan.
void CountDownAndWait() noexcept
Countdown the latch.
Latch(const Latch &)=delete
void Wait() noexcept
Wait for the latch.
C++ Common project definitions.