libcopp  2.2.0
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
coroutine_context_base Class Reference

base type of all coroutine context More...

#include <coroutine_context_base.h>

Inheritance diagram for coroutine_context_base:
Inheritance graph
Collaboration diagram for coroutine_context_base:
Collaboration graph

Data Structures

struct  flag_type
 
struct  status_type
 status of safe coroutine context base More...
 

Public Types

using callback_type = std::function< int(void *)>
 
using callback_t = callback_type
 
using status_t = status_type
 
using flag_t = flag_type
 

Public Member Functions

LIBCOPP_COPP_API ~coroutine_context_base ()
 
LIBCOPP_COPP_API bool set_flags (int flags) LIBCOPP_MACRO_NOEXCEPT
 set all flags to true More...
 
LIBCOPP_COPP_API bool unset_flags (int flags) LIBCOPP_MACRO_NOEXCEPT
 set all flags to false More...
 
LIBCOPP_COPP_API bool check_flags (int flags) const LIBCOPP_MACRO_NOEXCEPT
 check flags More...
 
LIBCOPP_COPP_API int set_runner (callback_type &&runner)
 set runner More...
 
UTIL_FORCEINLINE const std::function< int(void *)> & get_runner () const LIBCOPP_MACRO_NOEXCEPT
 
UTIL_FORCEINLINE int get_ret_code () const LIBCOPP_MACRO_NOEXCEPT
 get runner return code More...
 
LIBCOPP_COPP_API bool is_finished () const LIBCOPP_MACRO_NOEXCEPT
 get runner return code More...
 
UTIL_FORCEINLINE void * get_private_buffer () const LIBCOPP_MACRO_NOEXCEPT
 get private buffer(raw pointer) More...
 
UTIL_FORCEINLINE size_t get_private_buffer_size () const LIBCOPP_MACRO_NOEXCEPT
 get private buffer size More...
 

Static Public Member Functions

static UTIL_FORCEINLINE size_t align_private_data_size (size_t sz)
 
static size_t align_address_size (size_t sz)
 
static size_t align_stack_size (size_t sz)
 
static LIBCOPP_COPP_API coroutine_context_baseget_this_coroutine_base () LIBCOPP_MACRO_NOEXCEPT
 get current coroutine More...
 
static LIBCOPP_COPP_API void set_this_coroutine_base (coroutine_context_base *ctx) LIBCOPP_MACRO_NOEXCEPT
 set current coroutine More...
 

Protected Member Functions

LIBCOPP_COPP_API coroutine_context_base () LIBCOPP_MACRO_NOEXCEPT
 
UTIL_FORCEINLINE void run_and_recv_retcode (void *priv_data)
 coroutine entrance function More...
 

Protected Attributes

int runner_ret_code_
 
int flags_
 
callback_type runner_
 
void * priv_data_
 
size_t private_buffer_size_
 
LIBCOPP_COPP_NAMESPACE_ID::util::lock::atomic_int_type< int > status_
 

Private Member Functions

 coroutine_context_base (const coroutine_context_base &)=delete
 
coroutine_context_baseoperator= (const coroutine_context_base &)=delete
 
 coroutine_context_base (const coroutine_context_base &&)=delete
 
coroutine_context_baseoperator= (const coroutine_context_base &&)=delete
 

Detailed Description

base type of all coroutine context

Definition at line 72 of file coroutine_context_base.h.

Member Typedef Documentation

◆ callback_t

Definition at line 99 of file coroutine_context_base.h.

◆ callback_type

using coroutine_context_base::callback_type = std::function<int(void *)>

Definition at line 74 of file coroutine_context_base.h.

◆ flag_t

Definition at line 101 of file coroutine_context_base.h.

◆ status_t

Definition at line 100 of file coroutine_context_base.h.

Constructor & Destructor Documentation

◆ coroutine_context_base() [1/3]

LIBCOPP_COPP_API coroutine_context_base::coroutine_context_base ( )
protected

status

Definition at line 70 of file coroutine_context.cpp.

◆ ~coroutine_context_base()

LIBCOPP_COPP_API coroutine_context_base::~coroutine_context_base ( )

Definition at line 78 of file coroutine_context.cpp.

◆ coroutine_context_base() [2/3]

coroutine_context_base::coroutine_context_base ( const coroutine_context_base )
privatedelete

◆ coroutine_context_base() [3/3]

coroutine_context_base::coroutine_context_base ( const coroutine_context_base &&  )
privatedelete

Member Function Documentation

◆ align_address_size()

static size_t coroutine_context_base::align_address_size ( size_t  sz)
inlinestatic

◆ align_private_data_size()

static UTIL_FORCEINLINE size_t coroutine_context_base::align_private_data_size ( size_t  sz)
inlinestatic

◆ align_stack_size()

static size_t coroutine_context_base::align_stack_size ( size_t  sz)
inlinestatic

Definition at line 227 of file coroutine_context_base.h.

References COROUTINE_CONTEXT_STACK_ALIGN_UNIT_SIZE.

◆ check_flags()

LIBCOPP_COPP_API bool coroutine_context_base::check_flags ( int  flags) const

check flags

Parameters
flagsflags to be checked
Returns
true if flags any flags is true

Definition at line 98 of file coroutine_context.cpp.

Referenced by this_coroutine::get_coroutine(), and coroutine_context::start().

◆ get_private_buffer()

UTIL_FORCEINLINE void* coroutine_context_base::get_private_buffer ( ) const
inline

get private buffer(raw pointer)

Definition at line 195 of file coroutine_context_base.h.

References priv_data_.

◆ get_private_buffer_size()

UTIL_FORCEINLINE size_t coroutine_context_base::get_private_buffer_size ( ) const
inline

get private buffer size

Definition at line 200 of file coroutine_context_base.h.

References private_buffer_size_.

◆ get_ret_code()

UTIL_FORCEINLINE int coroutine_context_base::get_ret_code ( ) const
inline

get runner return code

Returns

Definition at line 184 of file coroutine_context_base.h.

References runner_ret_code_.

◆ get_runner()

UTIL_FORCEINLINE const std::function<int(void *)>& coroutine_context_base::get_runner ( ) const
inline

get runner of this coroutine context (const)

Returns
nullptr of pointer of runner

Definition at line 178 of file coroutine_context_base.h.

References runner_.

◆ get_this_coroutine_base()

LIBCOPP_COPP_API coroutine_context_base * coroutine_context_base::get_this_coroutine_base ( )
static

get current coroutine

See also
detail::coroutine_context_base
Returns
pointer of current coroutine, if not in coroutine, return nullptr

Definition at line 123 of file coroutine_context.cpp.

References detail::get_this_coroutine_context().

◆ is_finished()

LIBCOPP_COPP_API bool coroutine_context_base::is_finished ( ) const

get runner return code

Returns
true if coroutine has run and finished

Definition at line 118 of file coroutine_context.cpp.

References coroutine_context_base::status_type::EN_CRS_FINISHED, util::lock::memory_order_acquire, and status_.

◆ operator=() [1/2]

coroutine_context_base& coroutine_context_base::operator= ( const coroutine_context_base &&  )
privatedelete

◆ operator=() [2/2]

coroutine_context_base& coroutine_context_base::operator= ( const coroutine_context_base )
privatedelete

◆ run_and_recv_retcode()

UTIL_FORCEINLINE void coroutine_context_base::run_and_recv_retcode ( void *  priv_data)
inlineprotected

coroutine entrance function

Definition at line 160 of file coroutine_context_base.h.

References runner_, and runner_ret_code_.

Referenced by libcopp_internal_api_set::coroutine_context_callback().

◆ set_flags()

LIBCOPP_COPP_API bool coroutine_context_base::set_flags ( int  flags)

set all flags to true

Parameters
flags(flags & EN_CFT_MASK) must be 0
Returns
true if flags is available, or return false

Definition at line 80 of file coroutine_context.cpp.

◆ set_runner()

LIBCOPP_COPP_API int coroutine_context_base::set_runner ( callback_type &&  runner)

◆ set_this_coroutine_base()

LIBCOPP_COPP_API void coroutine_context_base::set_this_coroutine_base ( coroutine_context_base ctx)
static

set current coroutine

See also
detail::coroutine_context_base
Parameters
ctxpointer of current coroutine, if not in coroutine, set nullptr

Definition at line 127 of file coroutine_context.cpp.

References detail::set_this_coroutine_context().

◆ unset_flags()

LIBCOPP_COPP_API bool coroutine_context_base::unset_flags ( int  flags)

set all flags to false

Parameters
flags(flags & EN_CFT_MASK) must be 0
Returns
true if flags is available, or return false

Definition at line 89 of file coroutine_context.cpp.

Field Documentation

◆ flags_

int coroutine_context_base::flags_
protected

coroutine return code

Definition at line 105 of file coroutine_context_base.h.

◆ priv_data_

void* coroutine_context_base::priv_data_
protected

coroutine runner

Definition at line 107 of file coroutine_context_base.h.

Referenced by get_private_buffer().

◆ private_buffer_size_

size_t coroutine_context_base::private_buffer_size_
protected

Definition at line 108 of file coroutine_context_base.h.

Referenced by get_private_buffer_size().

◆ runner_

callback_type coroutine_context_base::runner_
protected

flags

Definition at line 106 of file coroutine_context_base.h.

Referenced by get_runner(), run_and_recv_retcode(), and set_runner().

◆ runner_ret_code_

int coroutine_context_base::runner_ret_code_
protected

Definition at line 104 of file coroutine_context_base.h.

Referenced by get_ret_code(), and run_and_recv_retcode().

◆ status_

LIBCOPP_COPP_NAMESPACE_ID::util::lock::atomic_int_type<int> coroutine_context_base::status_
protected

Definition at line 114 of file coroutine_context_base.h.

Referenced by is_finished(), and set_runner().


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