|
HikoGUI
A low latency retained GUI
|
#include <hikogui/scoped_task.hpp>
Data Structures | |
| struct | promise_type |
Public Types | |
| using | value_type = T |
| using | return_value_type = std::variant<std::monostate, std::exception_ptr, value_type> |
| The return value type. | |
| using | return_value_ptr_type = std::shared_ptr<return_value_type> |
| using | const_return_value_ptr_type = std::shared_ptr<return_value_type const> |
| using | notifier_type = notifier<void(value_type)> |
| using | handle_type = std::coroutine_handle<promise_type> |
Public Member Functions | |
| scoped_task (handle_type coroutine, const_return_value_ptr_type value_ptr) noexcept | |
| scoped_task (scoped_task const &)=delete | |
| scoped_task & | operator= (scoped_task const &)=delete |
| scoped_task (scoped_task &&other) noexcept | |
| scoped_task & | operator= (scoped_task &&other) noexcept |
| bool | completed () const noexcept |
| Check if the co-routine has completed. | |
| operator bool () const noexcept | |
| Check if the co-routine has completed. | |
| value_type const & | value () const |
| Get the return value returned from co_return. | |
| value_type const & | operator* () const |
| Get the return value returned from co_return. | |
| notifier_type::token_type | subscribe (std::invocable< value_type > auto &&callback) noexcept |
| Subscribe a callback for when the co-routine is completed. | |
A scoped_task.
Like the hi::task instance this implements a asynchronous co-routine task.
If the scoped_task object is destroyed, the potentially non-completed co-routine will be destroyed as well. A scoped_task is a move-only object.
| T | The type returned by co_return. |
| using v1::scoped_task< T >::return_value_type = std::variant<std::monostate, std::exception_ptr, value_type> |
The return value type.
This value is shared between the promise and the scoped_task. The variant has three different states:
|
inlinenoexcept |
Check if the co-routine has completed.
|
inlineexplicitnoexcept |
Check if the co-routine has completed.
|
inline |
Get the return value returned from co_return.
| The | exception thrown from the co-routine. |
|
inlinenoexcept |
Subscribe a callback for when the co-routine is completed.
| callback | The callback to call when the co-routine executed co_return. If co_return has a non-void expression then the callback must accept the expression as an argument. |
|
inline |
Get the return value returned from co_return.
| The | exception thrown from the co-routine. |