Implementation of a countdown latch for threading synchronization.
More...
#include <threading.h>
|
| latch (std::size_t count) |
| Create a new latch.
|
|
| latch (const latch &)=delete |
|
latch & | operator= (const latch &)=delete |
|
void | wait () const |
| Wait until the latch is unlocked.
|
|
template<typename Rep, typename Period> |
bool | wait_for (const std::chrono::duration< Rep, Period > &dur) const |
| Wait until the latch is unlocked, with a timeout.
|
|
template<typename Clock, typename Duration> |
bool | wait_until (const std::chrono::time_point< Clock, Duration > &tp) const |
| Wait until the latch is unlocked until a specific timepoint.
|
|
void | count_down (std::size_t n=1) |
| Counts down the internal counter.
|
|
Implementation of a countdown latch for threading synchronization.
This has roughly the same interface as std::latch, but that requires C++20, which we do not support.
- See also
- https://en.cppreference.com/w/cpp/thread/latch
◆ latch()
util::latch::latch |
( |
std::size_t | count | ) |
|
Create a new latch.
- Parameters
-
count | This is the number of countdowns before the latch is unlocked. |
◆ count_down()
void util::latch::count_down |
( |
std::size_t | n = 1 | ) |
|
Counts down the internal counter.
When the counter reaches 0 the latch is unlocked.
- Parameters
-
n | The amount to decrement by. |
◆ wait_for()
template<typename Rep, typename Period>
Wait until the latch is unlocked, with a timeout.
- Parameters
-
- Returns
- bool True if the latch was unlocked, false if timed out.
◆ wait_until()
template<typename Clock, typename Duration>
Wait until the latch is unlocked until a specific timepoint.
- Parameters
-
tp | The timepoint to wait until. |
- Returns
- bool True iff the latch was unlocked before the given time.
The documentation for this class was generated from the following files: