Future returned by Select() that polls multiple sub-futures until at least one completes.
SelectFuture owns its sub-futures by value and destroys all of them in place once Pend() returns Ready, cancelling any that did not complete.
Prefer constructing SelectFuture via Select(). To wait on the same futures repeatedly without destroying incomplete ones, use PW_SELECT or PW_CO_SELECT.
Public Types | |
| using | value_type = typename Traits::value_type |
Public Member Functions | |
| constexpr | SelectFuture ()=default |
Constructs an empty, non-pendable SelectFuture. | |
| template<bool kEnable = kValidFutures, std::enable_if_t< kEnable, int > = 0> | |
| constexpr | SelectFuture (Futures &&... futures) |
| SelectFuture (const SelectFuture &)=delete | |
| SelectFuture & | operator= (const SelectFuture &)=delete |
| SelectFuture (SelectFuture &&other) noexcept(kNothrowMove) | |
| SelectFuture & | operator= (SelectFuture &&other) noexcept(kNothrowMove) |
| ~SelectFuture ()=default | |
Destroys the SelectFuture, cancelling any active sub-futures. | |
| Poll< value_type > | Pend (Context &cx) |
| constexpr bool | is_pendable () const |
| constexpr bool | is_complete () const |
| using pw::async2::SelectFuture< Futures >::value_type = typename Traits::value_type |
Output type (OptionalTuple<FutureValue<Futures>...>) produced on completion, holding the output of each sub-future that completed.
|
inlineexplicitconstexpr |
Constructs a pendable SelectFuture that takes ownership of futures.
| [in] | futures | The sub-futures to poll concurrently. |
|
inlinenoexcept |
Move-constructs a SelectFuture, leaving other empty.
| [in,out] | other | The SelectFuture to move from. |
|
inlineconstexpr |
Checks whether the SelectFuture has completed.
true if a previous call to Pend() returned Ready.
|
inlineconstexpr |
Checks whether Pend() may be called.
true if the SelectFuture holds active sub-futures and has not yet completed.
|
inlinenoexcept |
Move-assigns from other, cancelling and destroying any active sub-futures in this and leaving other empty.
| [in,out] | other | The SelectFuture to move from. |
this.
|
inline |
Polls each pendable sub-future in order, completing once at least one returns Ready.
When Pend() returns Ready, all sub-futures (including any that did not complete) are immediately destroyed in place.
is_pendable() is true and at least one sub-future is pendable. | [in,out] | cx | The asynchronous Context used to register wakers. |
Ready with an OptionalTuple of all completed outputs if one or more sub-futures completed, or Pending otherwise.