Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. pw_async2
  5. Coroutines
  6. pw::async2::FallibleCoro< T, Handler > Class Template Reference
Loading...
Searching...
No Matches
pw::async2::FallibleCoro< T, Handler > Class Template Reference

Overview

template<typename T, typename Handler = Function<void()>>
class pw::async2::FallibleCoro< T, Handler >

A Future that runs a coroutine and handles allocation failure gracefully.

Created by calling coro.MakeFallible(...).

Public Types

using value_type = typename internal::AllocFailureFutureValueType< T, Handler >::type
 

Public Member Functions

template<typename H = Handler>
requires (!internal::IsFallibleCoro<std::remove_cvref_t<H>> && !internal::IsCoro<std::remove_cvref_t<H>> && internal::AllocFailureHandler<Handler, T> && std::constructible_from<Handler, H>)
constexpr FallibleCoro (H &&handler)
 
template<typename H = Handler>
requires internal::AllocFailureHandler<Handler, T> && std::constructible_from<Handler, H>
constexpr FallibleCoro (Coro< T > &&coro, H &&handler={})
 
 FallibleCoro (const FallibleCoro &)=delete
 
FallibleCoro & operator= (const FallibleCoro &)=delete
 
constexpr FallibleCoro (FallibleCoro &&other) noexcept
 
template<typename OtherHandler >
requires (!std::is_same_v<Handler, OtherHandler> && internal::AllocFailureHandler<Handler, T> && std::constructible_from<Handler, OtherHandler>)
constexpr FallibleCoro (FallibleCoro< T, OtherHandler > &&other) noexcept
 
constexpr FallibleCoro & operator= (FallibleCoro &&other) noexcept
 
template<typename OtherHandler >
requires (!std::is_same_v<Handler, OtherHandler> && !std::is_reference_v<Handler> && internal::AllocFailureHandler<Handler, T> && std::assignable_from<Handler&, OtherHandler>)
constexpr FallibleCoro & operator= (FallibleCoro< T, OtherHandler > &&other) noexcept
 
constexpr FallibleCoro & operator= (Coro< T > &&coro) noexcept
 
bool is_pendable () const
 
bool is_complete () const
 
Poll< value_type > Pend (Context &cx)
 

Constructor & Destructor Documentation

◆ FallibleCoro()

template<typename T , typename Handler = Function<void()>>
template<typename H = Handler>
requires (!internal::IsFallibleCoro<std::remove_cvref_t<H>> && !internal::IsCoro<std::remove_cvref_t<H>> && internal::AllocFailureHandler<Handler, T> && std::constructible_from<Handler, H>)
constexpr pw::async2::FallibleCoro< T, Handler >::FallibleCoro ( H &&  handler)
inlineexplicitconstexpr

Creates an empty FallibleCoro (is_pendable() is false) configured with an allocation failure handler.

A Coro<T> must be assigned before Pend() is called, or Pend() will crash.

Member Function Documentation

◆ operator=()

template<typename T , typename Handler = Function<void()>>
constexpr FallibleCoro & pw::async2::FallibleCoro< T, Handler >::operator= ( Coro< T > &&  coro)
inlineconstexprnoexcept

Replaces the inner coroutine while preserving the configured allocation failure handler.


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