Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
aria::async::Task< T > Class Template Reference

#include <task.hpp>

Public Types

using promise_type = detail::TaskPromise<T>
using handle_type = std::coroutine_handle<promise_type>

Public Member Functions

 Task () noexcept=default
 Task (handle_type h) noexcept
 Task (const Task &)=delete
Taskoperator= (const Task &)=delete
 Task (Task &&o) noexcept
Taskoperator= (Task &&o) noexcept
 ~Task ()
bool done () const noexcept
auto operator co_await () &&noexcept
 Make the task awaitable.
void start ()
 Eagerly start the task without awaiting it. Use blocking_get() if you need the result.
void start_detached () &&
 Start the task and detach it: the coroutine frame stays alive until the coroutine completes, even after this Task object is destroyed.
void start_detached_ ()
 Lvalue convenience used internally by AsyncCommand.
blocking_get ()
 Blocking accessor — only safe if the task body is synchronous (no real async).

Member Typedef Documentation

◆ promise_type

template<typename T>
using aria::async::Task< T >::promise_type = detail::TaskPromise<T>

◆ handle_type

template<typename T>
using aria::async::Task< T >::handle_type = std::coroutine_handle<promise_type>

Constructor & Destructor Documentation

◆ Task() [1/4]

template<typename T>
aria::async::Task< T >::Task ( )
defaultnoexcept

◆ Task() [2/4]

template<typename T>
aria::async::Task< T >::Task ( handle_type h)
inlineexplicitnoexcept

◆ Task() [3/4]

template<typename T>
aria::async::Task< T >::Task ( const Task< T > & )
delete

◆ Task() [4/4]

template<typename T>
aria::async::Task< T >::Task ( Task< T > && o)
inlinenoexcept

◆ ~Task()

template<typename T>
aria::async::Task< T >::~Task ( )
inline

Member Function Documentation

◆ operator=() [1/2]

template<typename T>
Task & aria::async::Task< T >::operator= ( const Task< T > & )
delete

◆ operator=() [2/2]

template<typename T>
Task & aria::async::Task< T >::operator= ( Task< T > && o)
inlinenoexcept

◆ done()

template<typename T>
bool aria::async::Task< T >::done ( ) const
inlinenodiscardnoexcept

◆ operator co_await()

template<typename T>
auto aria::async::Task< T >::operator co_await ( ) &&
inlinenoexcept

Make the task awaitable.

IMPORTANT: For a temporary co_await Task<T>{h} we must MOVE the handle into the awaiter, not copy it. Otherwise the temporary Task's destructor calls handle.destroy() while the coroutine is still executing, causing a use-after-free.

◆ start()

template<typename T>
void aria::async::Task< T >::start ( )
inline

Eagerly start the task without awaiting it. Use blocking_get() if you need the result.

◆ start_detached()

template<typename T>
void aria::async::Task< T >::start_detached ( ) &&
inline

Start the task and detach it: the coroutine frame stays alive until the coroutine completes, even after this Task object is destroyed.

The frame is automatically destroyed on completion — no leaks. Pass a fresh task or an already-completed task. An asynchronous operation must retain control of resuming a task already parked in it.

Detached final suspension is ready immediately: normal coroutine completion releases the frame, including any unobserved result or exception. No final awaiter destroys its own frame while returning a continuation handle. An already-completed task is just released.

◆ start_detached_()

template<typename T>
void aria::async::Task< T >::start_detached_ ( )
inline

Lvalue convenience used internally by AsyncCommand.

◆ blocking_get()

template<typename T>
T aria::async::Task< T >::blocking_get ( )
inline

Blocking accessor — only safe if the task body is synchronous (no real async).

For real async use co_await or a Scheduler.


The documentation for this class was generated from the following file:
  • modules/async/include/aria/async/task.hpp