#include <hikogui/scoped_task.hpp>
|
|
using | value_type = T |
| |
|
using | notifier_type = notifier<void(value_type)> |
| |
|
using | handle_type = std::coroutine_handle<promise_type> |
| |
|
|
| scoped_task (handle_type coroutine) 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 | done () 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 (callback_flags flags, std::invocable< value_type > auto &&callback) noexcept |
| | Subscribe a callback for when the co-routine is completed.
|
| |
| notifier_type::token_type | subscribe (std::invocable< value_type > auto &&callback) noexcept |
| | Subscribe a callback for when the co-routine is completed.
|
| |
template<typename T = void>
class v1::scoped_task< T >
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.
- Template Parameters
-
| T | The type returned by co_return. |
◆ done()
template<typename T = void>
Check if the co-routine has completed.
◆ operator bool()
template<typename T = void>
Check if the co-routine has completed.
◆ operator*()
template<typename T = void>
Get the return value returned from co_return.
- Note
- It is undefined behavior to call this function if the co-routine is incomplete.
- Exceptions
-
| The | exception thrown from the co-routine. |
◆ subscribe() [1/2]
template<typename T = void>
| notifier_type::token_type v1::scoped_task< T >::subscribe |
( |
callback_flags | flags, |
|
|
std::invocable< value_type > auto && | callback ) |
|
inlinenoexcept |
Subscribe a callback for when the co-routine is completed.
- Parameters
-
| 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. |
◆ subscribe() [2/2]
template<typename T = void>
| notifier_type::token_type v1::scoped_task< T >::subscribe |
( |
std::invocable< value_type > auto && | callback | ) |
|
|
inlinenoexcept |
Subscribe a callback for when the co-routine is completed.
- Parameters
-
| 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. |
◆ value()
template<typename T = void>
Get the return value returned from co_return.
- Note
- It is undefined behavior to call this function if the co-routine is incomplete.
- Exceptions
-
| The | exception thrown from the co-routine. |
The documentation for this class was generated from the following file: