The latch class is a downward counter of type std::size_t which can be used to synchronize coroutines.
More...
#include <asyncpp/latch.h>
|
| latch (std::size_t initial) noexcept |
| Constructs a latch and initializes its internal counter.
|
|
| latch (const latch &)=delete |
| latch is not copyable
|
|
latch & | operator= (const latch &)=delete |
| latch is not copyable
|
|
bool | is_ready () const noexcept |
| Check if the latch reached zero.
|
|
void | decrement (std::size_t n=1) noexcept |
| Decrement the latch counter.
|
|
auto | operator co_await () noexcept |
| Wait for the counter to reach zero.
|
|
auto | wait (dispatcher *resume_dispatcher=nullptr) noexcept |
| Wait for the counter to reach zero.
|
|
|
static constexpr std::size_t | max = std::numeric_limits<std::size_t>::max() |
| The maximum value of counter supported.
|
|
The latch class is a downward counter of type std::size_t which can be used to synchronize coroutines.
The value of the counter is initialized on creation. Threads may block on the latch until the counter is decremented to zero. There is no possibility to increase or reset the counter, which makes the latch a single-use barrier. Concurrent invocations of the member functions of latch
, except for the destructor, do not introduce data races.
◆ latch()
asyncpp::latch::latch |
( |
std::size_t | initial | ) |
|
|
inlineexplicitnoexcept |
Constructs a latch and initializes its internal counter.
- Parameters
-
initial | The initial counter value |
◆ decrement()
void asyncpp::latch::decrement |
( |
std::size_t | n = 1 | ) |
|
|
inlinenoexcept |
Decrement the latch counter.
- Parameters
-
n | Amount to decrement from the counter |
- Note
- It is undefined if the sum of all decrement calls exceeds the counter value.
The documentation for this class was generated from the following file: