CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::AsyncGenerator< T, Lockable >::Promise Class Referencefinal

Public Member Functions

AsyncGenerator get_return_object () noexcept
 
constexpr suspend_always initial_suspend () const noexcept
 
constexpr suspend_always final_suspend () const noexcept
 
template<typename U = T, std::enable_if_t<!std::is_rvalue_reference< U >::value, int > = 0>
Promiseyield_value (std::remove_reference_t< T > &value) noexcept
 Yields a new value to the generator.
 
Promiseyield_value (std::remove_reference_t< T > &&value) noexcept
 Yields a new value to the generator.
 
void unhandled_exception () noexcept
 A method called internally by the compiler when an exception is thrown in the coroutine.
 
void return_void () noexcept
 
bool await_ready () const noexcept
 
void await_suspend (const AsyncCoroutineHandle handle) noexcept
 
void await_resume () noexcept
 
Reference value () const noexcept
 
void rethrow ()
 If an exception was thrown in the coroutine, rethrows it.
 

Public Attributes

std::optional< Pointercurrent = nullptr
 The value returned by the last continuation of the coroutine.
 
std::exception_ptr exception = nullptr
 The exception throw by the coroutine.
 
AsyncCoroutineHandle task = nullptr
 The task currently being awaited.
 
Lockable mutex
 A lockable object that sychronizes access to the promise when executing asynchronous code.
 

Friends

class Iterator
 
class AsyncGenerator
 

Member Function Documentation

◆ await_ready()

template<typename T , typename Lockable = Mutex>
bool CeresEngine::AsyncGenerator< T, Lockable >::Promise::await_ready ( ) const
inlinenoexcept

◆ await_resume()

template<typename T , typename Lockable = Mutex>
void CeresEngine::AsyncGenerator< T, Lockable >::Promise::await_resume ( )
inlinenoexcept

◆ await_suspend()

template<typename T , typename Lockable = Mutex>
void CeresEngine::AsyncGenerator< T, Lockable >::Promise::await_suspend ( const AsyncCoroutineHandle  handle)
inlinenoexcept

◆ final_suspend()

template<typename T , typename Lockable = Mutex>
constexpr suspend_always CeresEngine::AsyncGenerator< T, Lockable >::Promise::final_suspend ( ) const
inlineconstexprnoexcept
Returns
suspend_always

◆ get_return_object()

template<typename T , typename Lockable = Mutex>
AsyncGenerator CeresEngine::AsyncGenerator< T, Lockable >::Promise::get_return_object ( )
inlinenoexcept

◆ initial_suspend()

template<typename T , typename Lockable = Mutex>
constexpr suspend_always CeresEngine::AsyncGenerator< T, Lockable >::Promise::initial_suspend ( ) const
inlineconstexprnoexcept
Returns
suspend_always

◆ rethrow()

template<typename T , typename Lockable = Mutex>
void CeresEngine::AsyncGenerator< T, Lockable >::Promise::rethrow ( )
inline

If an exception was thrown in the coroutine, rethrows it.

If no exception was thrown, this method does nothing.

◆ return_void()

template<typename T , typename Lockable = Mutex>
void CeresEngine::AsyncGenerator< T, Lockable >::Promise::return_void ( )
inlinenoexcept

◆ unhandled_exception()

template<typename T , typename Lockable = Mutex>
void CeresEngine::AsyncGenerator< T, Lockable >::Promise::unhandled_exception ( )
inlinenoexcept

A method called internally by the compiler when an exception is thrown in the coroutine.

This will setup the execption to that it is thrown when calling operator++.

◆ value()

template<typename T , typename Lockable = Mutex>
Reference CeresEngine::AsyncGenerator< T, Lockable >::Promise::value ( ) const
inlinenoexcept
Returns
A reference to the last yielded value

◆ yield_value() [1/2]

template<typename T , typename Lockable = Mutex>
Promise & CeresEngine::AsyncGenerator< T, Lockable >::Promise::yield_value ( std::remove_reference_t< T > &&  value)
inlinenoexcept

Yields a new value to the generator.

Parameters
valueThe value to be yielded to the generator
Returns
suspend_always

◆ yield_value() [2/2]

template<typename T , typename Lockable = Mutex>
template<typename U = T, std::enable_if_t<!std::is_rvalue_reference< U >::value, int > = 0>
Promise & CeresEngine::AsyncGenerator< T, Lockable >::Promise::yield_value ( std::remove_reference_t< T > &  value)
inlinenoexcept

Yields a new value to the generator.

Template Parameters
Uthe value type
Parameters
valueThe value to be yielded to the generator
Returns
suspend_always

Friends And Related Symbol Documentation

◆ AsyncGenerator

template<typename T , typename Lockable = Mutex>
friend class AsyncGenerator
friend

◆ Iterator

template<typename T , typename Lockable = Mutex>
friend class Iterator
friend

Member Data Documentation

◆ current

template<typename T , typename Lockable = Mutex>
std::optional<Pointer> CeresEngine::AsyncGenerator< T, Lockable >::Promise::current = nullptr

The value returned by the last continuation of the coroutine.

◆ exception

template<typename T , typename Lockable = Mutex>
std::exception_ptr CeresEngine::AsyncGenerator< T, Lockable >::Promise::exception = nullptr

The exception throw by the coroutine.

If no exception was thrown, this is ´nullptr`.

◆ mutex

template<typename T , typename Lockable = Mutex>
Lockable CeresEngine::AsyncGenerator< T, Lockable >::Promise::mutex
mutable

A lockable object that sychronizes access to the promise when executing asynchronous code.

◆ task

The task currently being awaited.


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