Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::barrier< CompletionFunction > Class Template Reference

A backport of std::barrier from C++20. More...

Public Member Functions

 barrier (barrier &&)=delete
 Not movable.
 
 barrier (barrier const &)=delete
 Not copyable.
 
template<typename F = CompletionFunction, constraints< std::enable_if_t< std::is_default_constructible< F >::value > > = nullptr>
constexpr barrier (std::ptrdiff_t count) noexcept(std::is_nothrow_default_constructible< F >::value)
 Construct a barrier with a specified count and default-constructed completion function.
 
constexpr barrier (std::ptrdiff_t count, CompletionFunction func) noexcept(std::is_nothrow_move_constructible< CompletionFunction >::value)
 Construct a barrier with a specified count and completion function.
 
 ~barrier ()=default
 Default destructor.
 
ARENE_NODISCARD auto arrive () -> arrival_token
 Arrive at the barrier, and obtain a token that can be used to wait for the end of the completion step associated with the current phase.
 
ARENE_NODISCARD auto arrive (std::ptrdiff_t arrivals) -> arrival_token
 Arrive at the barrier with the specified number of arrivals, and obtain a token that can be used to wait for the end of the completion step associated with the current phase.
 
void arrive_and_drop ()
 Decrease the number of arrivals required for the subsequent phases to end, and arrive at the barrier. May trigger the completion step. If the required number of arrivals is reduced to zero then the barrier has no more completion phases.
 
void arrive_and_wait ()
 Arrive at the barrier and wait for the completion step to end. May trigger the completion step.
 
auto operator= (barrier &&) -> barrier &=delete
 Not movable.
 
auto operator= (barrier const &) -> barrier &=delete
 Not copyable.
 
void wait (arrival_token token)
 Wait for the completion step associated with the phase identified by token to end.
 

Static Public Member Functions

static constexpr auto max () noexcept -> std::ptrdiff_t
 Get the maximum supported count.
 

Detailed Description

template<typename CompletionFunction = barrier_detail::default_completion_function>
class arene::base::barrier< CompletionFunction >

A backport of std::barrier from C++20.

Template Parameters
CompletionFunctionThe type of the completion function. Defaults to an invocable type with a do-nothing function call operator.
Precondition
CompletionFunction must be destructible, move-constructible and nothrow-invocable.

Constructor & Destructor Documentation

◆ barrier() [1/4]

template<typename CompletionFunction = barrier_detail::default_completion_function>
arene::base::barrier< CompletionFunction >::barrier ( std::ptrdiff_t count,
CompletionFunction func )
inlineconstexprnoexcept

Construct a barrier with a specified count and completion function.

Parameters
countThe initial number of arrivals required to complete each phase
funcThe completion function to invoke at the end of each phase

◆ barrier() [2/4]

template<typename CompletionFunction = barrier_detail::default_completion_function>
template<typename F = CompletionFunction, constraints< std::enable_if_t< std::is_default_constructible< F >::value > > = nullptr>
arene::base::barrier< CompletionFunction >::barrier ( std::ptrdiff_t count)
inlineexplicitconstexprnoexcept

Construct a barrier with a specified count and default-constructed completion function.

Parameters
countThe initial number of arrivals required to complete each phase

◆ ~barrier()

template<typename CompletionFunction = barrier_detail::default_completion_function>
arene::base::barrier< CompletionFunction >::~barrier ( )
default

Default destructor.

◆ barrier() [3/4]

template<typename CompletionFunction = barrier_detail::default_completion_function>
arene::base::barrier< CompletionFunction >::barrier ( barrier< CompletionFunction > const & )
delete

Not copyable.

◆ barrier() [4/4]

template<typename CompletionFunction = barrier_detail::default_completion_function>
arene::base::barrier< CompletionFunction >::barrier ( barrier< CompletionFunction > && )
delete

Not movable.

Member Function Documentation

◆ arrive() [1/2]

template<typename CompletionFunction = barrier_detail::default_completion_function>
ARENE_NODISCARD auto arene::base::barrier< CompletionFunction >::arrive ( ) -> arrival_token
inline

Arrive at the barrier, and obtain a token that can be used to wait for the end of the completion step associated with the current phase.

Returns
An arrival_token associated with the current phase

◆ arrive() [2/2]

template<typename CompletionFunction = barrier_detail::default_completion_function>
ARENE_NODISCARD auto arene::base::barrier< CompletionFunction >::arrive ( std::ptrdiff_t arrivals) -> arrival_token
inline

Arrive at the barrier with the specified number of arrivals, and obtain a token that can be used to wait for the end of the completion step associated with the current phase.

Parameters
arrivalsThe number of arrivals
Returns
An arrival_token associated with the current phase
Precondition
arrivals must be greater than zero, and less than or equal to the remaining number of arrivals required in the current phase.

◆ arrive_and_drop()

template<typename CompletionFunction = barrier_detail::default_completion_function>
void arene::base::barrier< CompletionFunction >::arrive_and_drop ( )
inline

Decrease the number of arrivals required for the subsequent phases to end, and arrive at the barrier. May trigger the completion step. If the required number of arrivals is reduced to zero then the barrier has no more completion phases.

Precondition
The remaining count for the current phase it at least one.

◆ arrive_and_wait()

template<typename CompletionFunction = barrier_detail::default_completion_function>
void arene::base::barrier< CompletionFunction >::arrive_and_wait ( )
inline

Arrive at the barrier and wait for the completion step to end. May trigger the completion step.

Precondition
The remaining count for the current phase it at least one.

◆ max()

template<typename CompletionFunction = barrier_detail::default_completion_function>
static constexpr auto arene::base::barrier< CompletionFunction >::max ( ) -> std::ptrdiff_t
inlinestaticconstexprnoexcept

Get the maximum supported count.

Returns
The maximum count

◆ operator=() [1/2]

template<typename CompletionFunction = barrier_detail::default_completion_function>
auto arene::base::barrier< CompletionFunction >::operator= ( barrier< CompletionFunction > && ) -> barrier &=delete
delete

Not movable.

◆ operator=() [2/2]

template<typename CompletionFunction = barrier_detail::default_completion_function>
auto arene::base::barrier< CompletionFunction >::operator= ( barrier< CompletionFunction > const & ) -> barrier &=delete
delete

Not copyable.

◆ wait()

template<typename CompletionFunction = barrier_detail::default_completion_function>
void arene::base::barrier< CompletionFunction >::wait ( arrival_token token)
inline

Wait for the completion step associated with the phase identified by token to end.

Parameters
tokenA token returned from arrive
Precondition
token must be associated with the current phase, or the previous one.

The documentation for this class was generated from the following file: