libcopp
2.2.0
|
base type of all coroutine context More...
#include <coroutine_context_base.h>
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_base * | get_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_base & | operator= (const coroutine_context_base &)=delete |
coroutine_context_base (const coroutine_context_base &&)=delete | |
coroutine_context_base & | operator= (const coroutine_context_base &&)=delete |
base type of all coroutine context
Definition at line 72 of file coroutine_context_base.h.
Definition at line 99 of file coroutine_context_base.h.
using coroutine_context_base::callback_type = std::function<int(void *)> |
Definition at line 74 of file coroutine_context_base.h.
Definition at line 101 of file coroutine_context_base.h.
Definition at line 100 of file coroutine_context_base.h.
|
protected |
status
Definition at line 70 of file coroutine_context.cpp.
LIBCOPP_COPP_API coroutine_context_base::~coroutine_context_base | ( | ) |
Definition at line 78 of file coroutine_context.cpp.
|
privatedelete |
|
privatedelete |
|
inlinestatic |
Definition at line 219 of file coroutine_context_base.h.
References COROUTINE_CONTEXT_BASE_ALIGN_UNIT_SIZE.
Referenced by coroutine_context_container< TALLOC >::create().
|
inlinestatic |
Definition at line 203 of file coroutine_context_base.h.
References COROUTINE_CONTEXT_BASE_ALIGN_UNIT_SIZE.
Referenced by coroutine_context_container< TALLOC >::create().
|
inlinestatic |
Definition at line 227 of file coroutine_context_base.h.
References COROUTINE_CONTEXT_STACK_ALIGN_UNIT_SIZE.
LIBCOPP_COPP_API bool coroutine_context_base::check_flags | ( | int | flags | ) | const |
check flags
flags | flags to be checked |
Definition at line 98 of file coroutine_context.cpp.
Referenced by this_coroutine::get_coroutine(), and coroutine_context::start().
|
inline |
get private buffer(raw pointer)
Definition at line 195 of file coroutine_context_base.h.
References priv_data_.
|
inline |
get private buffer size
Definition at line 200 of file coroutine_context_base.h.
References private_buffer_size_.
|
inline |
get runner return code
Definition at line 184 of file coroutine_context_base.h.
References runner_ret_code_.
|
inline |
get runner of this coroutine context (const)
Definition at line 178 of file coroutine_context_base.h.
References runner_.
|
static |
get current coroutine
Definition at line 123 of file coroutine_context.cpp.
References detail::get_this_coroutine_context().
LIBCOPP_COPP_API bool coroutine_context_base::is_finished | ( | ) | const |
get runner return code
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_.
|
privatedelete |
|
privatedelete |
|
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().
LIBCOPP_COPP_API bool coroutine_context_base::set_flags | ( | int | flags | ) |
set all flags to true
flags | (flags & EN_CFT_MASK) must be 0 |
Definition at line 80 of file coroutine_context.cpp.
LIBCOPP_COPP_API int coroutine_context_base::set_runner | ( | callback_type && | runner | ) |
set runner
runner |
Definition at line 102 of file coroutine_context.cpp.
References COPP_EC_ALREADY_INITED, COPP_EC_ARGS_ERROR, COPP_EC_SUCCESS, coroutine_context_base::status_type::EN_CRS_INVALID, coroutine_context_base::status_type::EN_CRS_READY, util::lock::memory_order_acq_rel, util::lock::memory_order_acquire, runner_, and status_.
|
static |
set current coroutine
ctx | pointer of current coroutine, if not in coroutine, set nullptr |
Definition at line 127 of file coroutine_context.cpp.
References detail::set_this_coroutine_context().
LIBCOPP_COPP_API bool coroutine_context_base::unset_flags | ( | int | flags | ) |
set all flags to false
flags | (flags & EN_CFT_MASK) must be 0 |
Definition at line 89 of file coroutine_context.cpp.
|
protected |
coroutine return code
Definition at line 105 of file coroutine_context_base.h.
|
protected |
coroutine runner
Definition at line 107 of file coroutine_context_base.h.
Referenced by get_private_buffer().
|
protected |
Definition at line 108 of file coroutine_context_base.h.
Referenced by get_private_buffer_size().
|
protected |
flags
Definition at line 106 of file coroutine_context_base.h.
Referenced by get_runner(), run_and_recv_retcode(), and set_runner().
|
protected |
Definition at line 104 of file coroutine_context_base.h.
Referenced by get_ret_code(), and run_and_recv_retcode().
|
protected |
Definition at line 114 of file coroutine_context_base.h.
Referenced by is_finished(), and set_runner().