HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions
v1::task< T, DestroyFrame > Class Template Reference

#include <hikogui/dispatch/task.hpp>

Data Structures

struct  promise_type
 

Public Types

using value_type = T
 
using notifier_type = notifier<void(value_type)>
 
using callback_type = notifier_type::callback_type
 
using handle_type = std::coroutine_handle<promise_type>
 

Public Member Functions

 task (handle_type coroutine) noexcept
 
 task (task const &)=delete
 
taskoperator= (task const &)=delete
 
 task (task &&other) noexcept
 
taskoperator= (task &&other) noexcept
 
bool started () const noexcept
 Check if the co-routine was started.
 
bool running () const noexcept
 Check if the co-routine is running.
 
bool done () 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.
 
template<forward_of< void(value_type)> Func>
callback< void(value_type)> subscribe (Func &&func, callback_flags flags=callback_flags::synchronous) noexcept
 Subscribe a callback for when the co-routine is completed.
 
auto operator co_await () const noexcept
 Create an awaiter that can await on this task.
 

Detailed Description

template<typename T = void, bool DestroyFrame = false>
class v1::task< T, DestroyFrame >

A task.

This implements a asynchronous co-routine task.

Template Parameters
TThe type returned by co_return.
DestroyFrameDestroy the coroutine frame when task goes out of scope.

Member Function Documentation

◆ done()

template<typename T = void, bool DestroyFrame = false>
bool v1::task< T, DestroyFrame >::done ( ) const
inlinenoexcept

Check if the co-routine has completed.

◆ operator co_await()

template<typename T = void, bool DestroyFrame = false>
auto v1::task< T, DestroyFrame >::operator co_await ( ) const
inlinenoexcept

Create an awaiter that can await on this task.

◆ operator*()

template<typename T = void, bool DestroyFrame = false>
value_type const & v1::task< T, DestroyFrame >::operator* ( ) const
inline

Get the return value returned from co_return.

Note
It is undefined behavior to call this function if the co-routine is incomplete.
Exceptions
Theexception thrown from the co-routine.

◆ running()

template<typename T = void, bool DestroyFrame = false>
bool v1::task< T, DestroyFrame >::running ( ) const
inlinenoexcept

Check if the co-routine is running.

◆ started()

template<typename T = void, bool DestroyFrame = false>
bool v1::task< T, DestroyFrame >::started ( ) const
inlinenoexcept

Check if the co-routine was started.

◆ subscribe()

template<typename T = void, bool DestroyFrame = false>
template<forward_of< void(value_type)> Func>
callback< void(value_type)> v1::task< T, DestroyFrame >::subscribe ( Func && func,
callback_flags flags = callback_flags::synchronous )
inlinenoexcept

Subscribe a callback for when the co-routine is completed.

Parameters
flagsThe callback flags used to be passed to the notifier.
callbackThe 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.
Returns
The callback token used to manage the lifetime of the callback

◆ value()

template<typename T = void, bool DestroyFrame = false>
value_type const & v1::task< T, DestroyFrame >::value ( ) const
inline

Get the return value returned from co_return.

Note
It is undefined behavior to call this function if the co-routine is incomplete.
Exceptions
Theexception thrown from the co-routine.

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