HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions
v1::scoped_task< void > Class Reference

#include <hikogui/scoped_task.hpp>

Data Structures

struct  promise_type
 

Public Types

using value_type = void
 
using return_value_type = std::variant<std::monostate, std::exception_ptr, std::monostate>
 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()>
 
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_taskoperator= (scoped_task const &)=delete
 
 scoped_task (scoped_task &&other) noexcept
 
scoped_taskoperator= (scoped_task &&other) noexcept
 
bool completed () const noexcept
 
 operator bool () const noexcept
 
void value () const
 Get the return value returned from co_return.
 
notifier_type::token_type subscribe (std::invocable<> auto &&callback) noexcept
 

Detailed Description

See also
scoped_task<>

Member Typedef Documentation

◆ return_value_type

using v1::scoped_task< void >::return_value_type = std::variant<std::monostate, std::exception_ptr, std::monostate>

The return value type.

This value is shared between the promise and the scoped_task. The variant has three different states:

  • 0: co-routine has not completed.
  • 1: co-routine caught an uncaught exception.
  • 2: co-routine is completed.

Member Function Documentation

◆ completed()

bool v1::scoped_task< void >::completed ( ) const
inlinenoexcept

◆ operator bool()

v1::scoped_task< void >::operator bool ( ) const
inlineexplicitnoexcept

◆ subscribe()

notifier_type::token_type v1::scoped_task< void >::subscribe ( std::invocable<> auto && callback)
inlinenoexcept

◆ value()

void v1::scoped_task< void >::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.
Returns
void
Exceptions
Theexception thrown from the co-routine.

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