|
| | Task ()=default |
| | Creates a task with no coroutine attached.
|
| | ~Task () |
| | Destroys the task and its coroutine state.
|
| | Task (std::coroutine_handle< promise_type > coroutine) |
| | Adopts an existing coroutine handle.
|
|
| Task (const Task &)=delete |
|
Task & | operator= (const Task &)=delete |
| | Task (Task &&other) noexcept |
| | Takes over another task's coroutine, leaving it empty.
|
| Task & | operator= (Task &&other) noexcept |
| | Takes over another task's coroutine, leaving it empty.
|
| bool | is_ready () const |
| | Reports whether the value is already available.
|
| TResult | result () |
| | Waits for the operation to finish and returns its value.
|
| auto | operator co_await () |
| | Makes the task awaitable, so co_await yields its value.
|
template<typename TResult>
class stripekit::Task< TResult >
The result of an asynchronous StripeKit operation.
Every *_async method returns one of these. co_await it to get the value:
A Stripe customer: the account everything else is billed against.
Outside a coroutine, result() blocks until the value is ready. That is convenient in command-line tools and tests, but must never be done on a thread that is running an event loop, since the work being waited on may need that loop to make progress.
The task starts on the first co_await or result(), not on construction, so a task that is created and dropped never runs. Tasks are move-only, and each one produces its value once.
- Template Parameters
-
| TResult | Type of value the operation produces. |
Definition at line 45 of file Async.h.
template<typename TResult>
Waits for the operation to finish and returns its value.
Starts the operation if it has not started yet, then blocks the calling thread. Do not call this from an event loop thread: the work being waited on may need that loop to run, which would deadlock. Prefer co_await.
- Returns
- The produced value, moved out of the task.
- Exceptions
-
| std::runtime_error | The task is empty. |
| StripeApiException | Or any other exception the operation threw. |
Definition at line 205 of file Async.h.
template<typename TResult>
Makes the task awaitable, so co_await yields its value.
Starts the operation if it has not started yet, suspends the awaiting coroutine, and resumes it with the value. An exception thrown by the operation is rethrown at the co_await.
- Returns
- The awaiter used by the compiler.
Definition at line 233 of file Async.h.