11 inline Latch::Latch(
int threads) noexcept : _generation(0), _threads(threads)
13 assert((threads > 0) &&
"Latch threads counter must be greater than zero!");
18 std::unique_lock<std::mutex> lock(_mutex);
25 int generation = _generation;
28 return _cond.wait_for(lock, timespan.chrono(), [&,
this]() { return generation != _generation; });
33 std::unique_lock<std::mutex> lock(_mutex);
40 int generation = _generation;
43 return _cond.wait_until(lock, timestamp.chrono(), [&,
this]() { return generation != _generation; });
bool TryWaitUntil(const Timestamp ×tamp) noexcept
Try to wait for the latch until the given timestamp.
Latch(int threads) noexcept
Default class constructor.
bool TryWaitFor(const Timespan ×pan) noexcept
Try to wait for the latch for the given timespan.
C++ Common project definitions.