StripeKit 0.1.1
Stripe integration toolkit for C++
Loading...
Searching...
No Matches
stripekit::Task< TResult >::promise_type Struct Reference

Coroutine promise type. More...

#include <Async.h>

Public Member Functions

Task get_return_object ()
 Creates the task object handed back to the caller.
std::suspend_always initial_suspend () noexcept
 Suspends the coroutine at its start so the caller controls when it runs.
auto final_suspend () noexcept
 Wakes anything waiting on this task once it finishes.
void return_value (TResult value)
 Stores the value the coroutine returned.
void unhandled_exception ()
 Captures an escaping exception so it can be rethrown to the waiter.

Public Attributes

std::optional< TResult > result
 The produced value, once available.
std::exception_ptr error
 The exception that escaped, if one did.
std::mutex mutex
 Guards the fields below.
std::condition_variable ready
 Signalled when the coroutine finishes.
std::coroutine_handle continuation
 Coroutine waiting on this task.
bool started = false
 True once the coroutine has been resumed.
bool completed = false
 True once the coroutine has finished.

Detailed Description

template<typename TResult>
struct stripekit::Task< TResult >::promise_type

Coroutine promise type.

Used by the compiler; not called directly.

Definition at line 50 of file Async.h.

Member Function Documentation

◆ get_return_object()

template<typename TResult>
Task stripekit::Task< TResult >::promise_type::get_return_object ( )
inline

Creates the task object handed back to the caller.

Returns
The task wrapping this coroutine.

Definition at line 56 of file Async.h.

◆ initial_suspend()

template<typename TResult>
std::suspend_always stripekit::Task< TResult >::promise_type::initial_suspend ( )
inlinenoexcept

Suspends the coroutine at its start so the caller controls when it runs.

Returns
An awaitable that always suspends.

Definition at line 65 of file Async.h.

◆ final_suspend()

template<typename TResult>
auto stripekit::Task< TResult >::promise_type::final_suspend ( )
inlinenoexcept

Wakes anything waiting on this task once it finishes.

Returns
An awaitable that notifies waiters and resumes the awaiting coroutine.

Definition at line 75 of file Async.h.

◆ return_value()

template<typename TResult>
void stripekit::Task< TResult >::promise_type::return_value ( TResult value)
inline

Stores the value the coroutine returned.

Parameters
valueThe produced value.

Definition at line 112 of file Async.h.

◆ unhandled_exception()

template<typename TResult>
void stripekit::Task< TResult >::promise_type::unhandled_exception ( )
inline

Captures an escaping exception so it can be rethrown to the waiter.

Definition at line 119 of file Async.h.

Member Data Documentation

◆ result

template<typename TResult>
std::optional<TResult> stripekit::Task< TResult >::promise_type::result

The produced value, once available.

Definition at line 123 of file Async.h.

◆ error

template<typename TResult>
std::exception_ptr stripekit::Task< TResult >::promise_type::error

The exception that escaped, if one did.

Definition at line 124 of file Async.h.

◆ mutex

template<typename TResult>
std::mutex stripekit::Task< TResult >::promise_type::mutex

Guards the fields below.

Definition at line 125 of file Async.h.

◆ ready

template<typename TResult>
std::condition_variable stripekit::Task< TResult >::promise_type::ready

Signalled when the coroutine finishes.

Definition at line 126 of file Async.h.

◆ continuation

template<typename TResult>
std::coroutine_handle stripekit::Task< TResult >::promise_type::continuation

Coroutine waiting on this task.

Definition at line 127 of file Async.h.

◆ started

template<typename TResult>
bool stripekit::Task< TResult >::promise_type::started = false

True once the coroutine has been resumed.

Definition at line 128 of file Async.h.

◆ completed

template<typename TResult>
bool stripekit::Task< TResult >::promise_type::completed = false

True once the coroutine has finished.

Definition at line 129 of file Async.h.


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