Backport of std::latch from C++20. Provides a count-down latch that stays permanently signalled when the count reaches zero. For a given instance, every call to count_down or arrive_and_wait synchronizes-with every call to wait or arrive_and_wait, and every call to try_wait that returns true.
More...
|
| | latch (latch &&)=delete |
| | Not movable.
|
| |
| | latch (latch const &)=delete |
| | Not copyable.
|
| |
| constexpr | latch (std::ptrdiff_t initial_count) |
| | Construct a latch with the specified count. If the count is zero, then the latch will be already signalled.
|
| |
| | ~latch ()=default |
| | Default destructor.
|
| |
| void | arrive_and_wait () |
| | Count down the latch by 1 and blocks the current thread waiting for the latch to be signalled.
|
| |
| void | arrive_and_wait (std::ptrdiff_t const update) |
| | Count down the latch by update and blocks the current thread waiting for the latch to be signalled.
|
| |
| void | count_down () |
| | Count down the latch by 1. If the counter reaches zero, the latch is permanently signalled, and any threads blocked in wait are unblocked.
|
| |
| void | count_down (std::ptrdiff_t update) |
| | Count down the latch by update. If the counter reaches zero, the latch is permanently signalled, and any threads blocked in wait are unblocked.
|
| |
| auto | operator= (latch &&) -> latch &=delete |
| | Not movable.
|
| |
| auto | operator= (latch const &) -> latch &=delete |
| | Not copyable.
|
| |
| auto | try_wait () const noexcept -> bool |
| | Check if the latch is signalled without blocking.
|
| |
| void | wait () const |
| | Blocks the current thread until the latch becomes signalled.
|
| |
|
| static constexpr auto | max () noexcept -> std::ptrdiff_t |
| | Get the maximum supported count.
|
| |
Backport of std::latch from C++20. Provides a count-down latch that stays permanently signalled when the count reaches zero. For a given instance, every call to count_down or arrive_and_wait synchronizes-with every call to wait or arrive_and_wait, and every call to try_wait that returns true.
◆ latch() [1/3]
Construct a latch with the specified count. If the count is zero, then the latch will be already signalled.
- Parameters
-
| initial_count | The initial count for the latch |
- Precondition
- initial_count >= 0
◆ ~latch()
| arene::base::latch::~latch |
( |
| ) |
|
|
default |
◆ latch() [2/3]
| arene::base::latch::latch |
( |
latch const & | | ) |
|
|
delete |
◆ latch() [3/3]
| arene::base::latch::latch |
( |
latch && | | ) |
|
|
delete |
◆ arrive_and_wait() [1/2]
| void arene::base::latch::arrive_and_wait |
( |
| ) |
|
|
inline |
Count down the latch by 1 and blocks the current thread waiting for the latch to be signalled.
- Exceptions
-
| std::system_error | on error |
◆ arrive_and_wait() [2/2]
| void arene::base::latch::arrive_and_wait |
( |
std::ptrdiff_t const | update | ) |
|
|
inline |
Count down the latch by update and blocks the current thread waiting for the latch to be signalled.
- Parameters
-
| update | The amount by which to decrease the count |
- Exceptions
-
| std::system_error | on error |
◆ count_down() [1/2]
| void arene::base::latch::count_down |
( |
| ) |
|
|
inline |
Count down the latch by 1. If the counter reaches zero, the latch is permanently signalled, and any threads blocked in wait are unblocked.
- Precondition
- The latch must not be signalled.
- Exceptions
-
| std::system_error | on error |
◆ count_down() [2/2]
Count down the latch by update. If the counter reaches zero, the latch is permanently signalled, and any threads blocked in wait are unblocked.
- Parameters
-
| update | The amount by which to decrease the count |
- Precondition
(update >= 0) && (update <= count_)
- Exceptions
-
| std::system_error | on error |
◆ max()
|
|
inlinestaticconstexprnoexcept |
Get the maximum supported count.
- Returns
- The maximum count
◆ operator=() [1/2]
| auto arene::base::latch::operator= |
( |
latch && | | ) |
-> latch &=delete |
|
delete |
◆ operator=() [2/2]
| auto arene::base::latch::operator= |
( |
latch const & | | ) |
-> latch &=delete |
|
delete |
◆ try_wait()
| auto arene::base::latch::try_wait |
( |
| ) |
const -> bool |
|
inlinenoexcept |
Check if the latch is signalled without blocking.
- Returns
true if the latch is signalled, false otherwise.
◆ wait()
| void arene::base::latch::wait |
( |
| ) |
const |
|
inline |
Blocks the current thread until the latch becomes signalled.
- Exceptions
-
| std::system_error | on error |
The documentation for this class was generated from the following file: