D++ (DPP)
C++ Discord API Bot Library
dpp::detail::coroutine::coroutine_base< R > Class Template Reference

Base class of dpp::coroutine<R>. More...

+ Collaboration diagram for dpp::detail::coroutine::coroutine_base< R >:

Public Member Functions

 coroutine_base ()=default
 Default constructor, creates an empty coroutine. More...
 
 coroutine_base (const coroutine_base &)=delete
 Copy constructor is disabled. More...
 
 coroutine_base (coroutine_base &&other) noexcept
 Move constructor, grabs another coroutine's handle. More...
 
 ~coroutine_base ()
 Destructor, destroys the handle. More...
 
coroutine_baseoperator= (const coroutine_base &)=delete
 Copy assignment is disabled. More...
 
coroutine_baseoperator= (coroutine_base &&other) noexcept
 Move assignment, grabs another coroutine's handle. More...
 
bool await_ready () const
 First function called by the standard library when the coroutine is co_await-ed. More...
 
template<typename T >
handle_t< R > await_suspend (detail::std_coroutine::coroutine_handle< T > caller) noexcept
 Second function called by the standard library when the coroutine is co_await-ed. More...
 
decltype(auto) await_resume () &
 Function called by the standard library when the coroutine is resumed. More...
 
decltype(auto) await_resume () const &
 Function called by the standard library when the coroutine is resumed. More...
 
decltype(auto) await_resume () &&
 Function called by the standard library when the coroutine is resumed. More...
 

Protected Attributes

detail::coroutine::handle_t< R > handle {nullptr}
 Coroutine handle. More...
 

Friends

struct promise_t< R >
 Promise has friend access for the constructor. More...
 

Detailed Description

template<typename R>
class dpp::detail::coroutine::coroutine_base< R >

Base class of dpp::coroutine<R>.

@warn This class should not be used directly by a user, use dpp::coroutine<R> instead.

Note
This class contains all the functions used internally by co_await. It is intentionally opaque and a private base of dpp::coroutine<R> so a user cannot call await_suspend and await_resume directly.

Constructor & Destructor Documentation

◆ coroutine_base() [1/3]

template<typename R >
dpp::detail::coroutine::coroutine_base< R >::coroutine_base ( )
default

Default constructor, creates an empty coroutine.

◆ coroutine_base() [2/3]

template<typename R >
dpp::detail::coroutine::coroutine_base< R >::coroutine_base ( const coroutine_base< R > &  )
delete

Copy constructor is disabled.

◆ coroutine_base() [3/3]

template<typename R >
dpp::detail::coroutine::coroutine_base< R >::coroutine_base ( coroutine_base< R > &&  other)
inlinenoexcept

Move constructor, grabs another coroutine's handle.

Parameters
otherCoroutine to move the handle from

◆ ~coroutine_base()

template<typename R >
dpp::detail::coroutine::coroutine_base< R >::~coroutine_base ( )
inline

Destructor, destroys the handle.

Member Function Documentation

◆ await_ready()

template<typename R >
bool dpp::detail::coroutine::coroutine_base< R >::await_ready ( ) const
inline

First function called by the standard library when the coroutine is co_await-ed.

Remarks
Do not call this manually, use the co_await keyword instead.
Exceptions
invalid_operation_exceptionif the coroutine is empty or finished.
Returns
bool Whether the coroutine is done

◆ await_resume() [1/3]

template<typename R >
decltype(auto) dpp::detail::coroutine::coroutine_base< R >::await_resume ( ) &
inline

Function called by the standard library when the coroutine is resumed.

Remarks
Do not call this manually, use the co_await keyword instead.
Exceptions
Throwsany exception thrown or uncaught by the coroutine
Returns
R The result of the coroutine. It is given to the caller as a result to co_await

◆ await_resume() [2/3]

template<typename R >
decltype(auto) dpp::detail::coroutine::coroutine_base< R >::await_resume ( ) &&
inline

Function called by the standard library when the coroutine is resumed.

Remarks
Do not call this manually, use the co_await keyword instead.
Exceptions
Throwsany exception thrown or uncaught by the coroutine
Returns
R The result of the coroutine. It is given to the caller as a result to co_await

◆ await_resume() [3/3]

template<typename R >
decltype(auto) dpp::detail::coroutine::coroutine_base< R >::await_resume ( ) const &
inline

Function called by the standard library when the coroutine is resumed.

Remarks
Do not call this manually, use the co_await keyword instead.
Exceptions
Throwsany exception thrown or uncaught by the coroutine
Returns
R The result of the coroutine. It is given to the caller as a result to co_await

◆ await_suspend()

template<typename R >
template<typename T >
handle_t<R> dpp::detail::coroutine::coroutine_base< R >::await_suspend ( detail::std_coroutine::coroutine_handle< T >  caller)
inlinenoexcept

Second function called by the standard library when the coroutine is co_await-ed.

Stores the calling coroutine in the promise to resume when this coroutine suspends.

Remarks
Do not call this manually, use the co_await keyword instead.
Parameters
callerThe calling coroutine, now suspended

◆ operator=() [1/2]

template<typename R >
coroutine_base& dpp::detail::coroutine::coroutine_base< R >::operator= ( const coroutine_base< R > &  )
delete

Copy assignment is disabled.

◆ operator=() [2/2]

template<typename R >
coroutine_base& dpp::detail::coroutine::coroutine_base< R >::operator= ( coroutine_base< R > &&  other)
inlinenoexcept

Move assignment, grabs another coroutine's handle.

Parameters
otherCoroutine to move the handle from

Friends And Related Function Documentation

◆ promise_t< R >

template<typename R >
friend struct promise_t< R >
friend

Promise has friend access for the constructor.

Member Data Documentation

◆ handle

template<typename R >
detail::coroutine::handle_t<R> dpp::detail::coroutine::coroutine_base< R >::handle {nullptr}
protected

Coroutine handle.

D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0