libcopp  2.2.0
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
impl::task_impl Class Referenceabstract

#include <task_impl.h>

Inheritance diagram for impl::task_impl:
Inheritance graph
Collaboration diagram for impl::task_impl:
Collaboration graph

Data Structures

struct  ext_coroutine_flag_t
 

Public Types

using id_type = LIBCOPP_COPP_NAMESPACE_ID::util::uint64_id_allocator::value_type
 
using id_allocator_type = LIBCOPP_COPP_NAMESPACE_ID::util::uint64_id_allocator
 
using id_t = id_type
 
using id_allocator_t = id_allocator_type
 

Public Member Functions

LIBCOPP_COTASK_API task_impl ()
 
virtual LIBCOPP_COTASK_API ~task_impl ()=0
 
UTIL_FORCEINLINE id_type get_id () const LIBCOPP_MACRO_NOEXCEPT
 
UTIL_FORCEINLINE EN_TASK_STATUS get_status () const LIBCOPP_MACRO_NOEXCEPT
 
virtual LIBCOPP_COTASK_API bool is_canceled () const LIBCOPP_MACRO_NOEXCEPT
 
virtual LIBCOPP_COTASK_API bool is_completed () const LIBCOPP_MACRO_NOEXCEPT
 
virtual LIBCOPP_COTASK_API bool is_faulted () const LIBCOPP_MACRO_NOEXCEPT
 
virtual LIBCOPP_COTASK_API bool is_timeout () const LIBCOPP_MACRO_NOEXCEPT
 
LIBCOPP_COTASK_API bool is_exiting () const LIBCOPP_MACRO_NOEXCEPT
 check if a cotask is exiting More...
 
virtual LIBCOPP_COTASK_API int get_ret_code () const =0
 
virtual int start (void *priv_data, EN_TASK_STATUS expected_status=EN_TS_CREATED)=0
 
virtual int resume (void *priv_data, EN_TASK_STATUS expected_status=EN_TS_WAITING)=0
 
virtual int yield (void **priv_data)=0
 
virtual int cancel (void *priv_data)=0
 
virtual int kill (enum EN_TASK_STATUS status, void *priv_data)=0
 
UTIL_FORCEINLINE int kill (void *priv_data)
 
UTIL_FORCEINLINE int start ()
 
UTIL_FORCEINLINE int resume ()
 
UTIL_FORCEINLINE int yield ()
 
UTIL_FORCEINLINE int cancel ()
 
UTIL_FORCEINLINE int kill (enum EN_TASK_STATUS status)
 
UTIL_FORCEINLINE int kill ()
 
virtual LIBCOPP_COTASK_API int on_finished ()
 
UTIL_FORCEINLINE action_ptr_type get_raw_action () const LIBCOPP_MACRO_NOEXCEPT
 get raw action pointer More...
 

Static Public Member Functions

static LIBCOPP_COTASK_API task_implthis_task ()
 

Protected Types

using action_ptr_type = task_action_impl *
 
using action_ptr_t = action_ptr_type
 

Protected Member Functions

LIBCOPP_COTASK_API void _set_action (action_ptr_type action)
 
LIBCOPP_COTASK_API action_ptr_type _get_action ()
 
LIBCOPP_COTASK_API bool _cas_status (EN_TASK_STATUS &expected, EN_TASK_STATUS desired)
 
LIBCOPP_COTASK_API int _notify_finished (void *priv_data)
 

Protected Attributes

void * finish_priv_data_
 

Private Member Functions

 task_impl (const task_impl &)=delete
 
task_imploperator= (const task_impl &)=delete
 
 task_impl (const task_impl &&)=delete
 
task_imploperator= (const task_impl &&)=delete
 

Private Attributes

action_ptr_type action_
 
id_type id_
 
LIBCOPP_COPP_NAMESPACE_ID::util::lock::atomic_int_type< uint32_t > status_
 

Detailed Description

Definition at line 40 of file task_impl.h.

Member Typedef Documentation

◆ action_ptr_t

Definition at line 53 of file task_impl.h.

◆ action_ptr_type

Definition at line 50 of file task_impl.h.

◆ id_allocator_t

Definition at line 47 of file task_impl.h.

◆ id_allocator_type

using impl::task_impl::id_allocator_type = LIBCOPP_COPP_NAMESPACE_ID::util::uint64_id_allocator

Definition at line 43 of file task_impl.h.

◆ id_t

Definition at line 46 of file task_impl.h.

◆ id_type

using impl::task_impl::id_type = LIBCOPP_COPP_NAMESPACE_ID::util::uint64_id_allocator::value_type

Definition at line 42 of file task_impl.h.

Constructor & Destructor Documentation

◆ task_impl() [1/3]

impl::task_impl::task_impl ( const task_impl )
privatedelete

◆ task_impl() [2/3]

impl::task_impl::task_impl ( const task_impl &&  )
privatedelete

◆ task_impl() [3/3]

LIBCOPP_COTASK_API impl::task_impl::task_impl ( )

Definition at line 23 of file task_impl.cpp.

References id_.

◆ ~task_impl()

LIBCOPP_COTASK_API impl::task_impl::~task_impl ( )
pure virtual

Definition at line 30 of file task_impl.cpp.

References EN_TS_DONE, and id_.

Member Function Documentation

◆ _cas_status()

LIBCOPP_COTASK_API bool impl::task_impl::_cas_status ( EN_TASK_STATUS expected,
EN_TASK_STATUS  desired 
)
protected

◆ _get_action()

LIBCOPP_COTASK_API task_impl::action_ptr_type impl::task_impl::_get_action ( )
protected

Definition at line 67 of file task_impl.cpp.

References action_.

Referenced by _notify_finished().

◆ _notify_finished()

LIBCOPP_COTASK_API int impl::task_impl::_notify_finished ( void *  priv_data)
protected

◆ _set_action()

LIBCOPP_COTASK_API void impl::task_impl::_set_action ( action_ptr_type  action)
protected

Definition at line 65 of file task_impl.cpp.

References print_color::action, and action_.

◆ cancel() [1/2]

UTIL_FORCEINLINE int impl::task_impl::cancel ( )
inline

Definition at line 110 of file task_impl.h.

References cancel().

Referenced by cancel().

◆ cancel() [2/2]

virtual int impl::task_impl::cancel ( void *  priv_data)
pure virtual

Implemented in task< TCO_MACRO >, and task< TCO_MACRO >.

◆ get_id()

UTIL_FORCEINLINE id_type impl::task_impl::get_id ( ) const
inline

Definition at line 74 of file task_impl.h.

Referenced by task_manager< task< TCO_MACRO > >::add_task(), and main().

◆ get_raw_action()

UTIL_FORCEINLINE action_ptr_type impl::task_impl::get_raw_action ( ) const
inline

get raw action pointer

Note
this function is provided just for debug or show some information, it may return the inner type created by cotask
Returns
pointer to task_action instance

Definition at line 132 of file task_impl.h.

◆ get_ret_code()

virtual LIBCOPP_COTASK_API int impl::task_impl::get_ret_code ( ) const
pure virtual

Implemented in task< TCO_MACRO >, and task< TCO_MACRO >.

◆ get_status()

UTIL_FORCEINLINE EN_TASK_STATUS impl::task_impl::get_status ( ) const
inline

◆ is_canceled()

LIBCOPP_COTASK_API bool impl::task_impl::is_canceled ( ) const
virtual

Definition at line 39 of file task_impl.cpp.

References EN_TS_CANCELED, and get_status().

◆ is_completed()

LIBCOPP_COTASK_API bool impl::task_impl::is_completed ( ) const
virtual

Reimplemented in task< TCO_MACRO >, and task< TCO_MACRO >.

Definition at line 41 of file task_impl.cpp.

References is_exiting().

Referenced by task< TCO_MACRO >::next(), and task< TCO_MACRO >::start().

◆ is_exiting()

LIBCOPP_COTASK_API bool impl::task_impl::is_exiting ( ) const

check if a cotask is exiting

Note
cotask is exiting means the cotask is is_completed() or is killed. if a cotask is killed and is running, then is_completed() == false but is_exiting() == true, and after the cotask finished, is_completed() == true
Returns
return true if a cotask is exiting.

Definition at line 47 of file task_impl.cpp.

References EN_TS_DONE, and get_status().

Referenced by task_manager< task< TCO_MACRO > >::add_task(), task< TCO_MACRO >::await_task(), is_completed(), and task< TCO_MACRO >::next().

◆ is_faulted()

LIBCOPP_COTASK_API bool impl::task_impl::is_faulted ( ) const
virtual

Definition at line 43 of file task_impl.cpp.

References EN_TS_KILLED, and get_status().

◆ is_timeout()

LIBCOPP_COTASK_API bool impl::task_impl::is_timeout ( ) const
virtual

Definition at line 45 of file task_impl.cpp.

References EN_TS_TIMEOUT, and get_status().

◆ kill() [1/4]

UTIL_FORCEINLINE int impl::task_impl::kill ( )
inline

Definition at line 112 of file task_impl.h.

References kill().

Referenced by kill(), and task< TCO_MACRO >::~task().

◆ kill() [2/4]

UTIL_FORCEINLINE int impl::task_impl::kill ( enum EN_TASK_STATUS  status)
inline

Definition at line 111 of file task_impl.h.

References kill().

Referenced by kill().

◆ kill() [3/4]

virtual int impl::task_impl::kill ( enum EN_TASK_STATUS  status,
void *  priv_data 
)
pure virtual

Implemented in task< TCO_MACRO >, and task< TCO_MACRO >.

◆ kill() [4/4]

UTIL_FORCEINLINE int impl::task_impl::kill ( void *  priv_data)
inline

Definition at line 105 of file task_impl.h.

References EN_TS_KILLED, and kill().

Referenced by kill().

◆ on_finished()

LIBCOPP_COTASK_API int impl::task_impl::on_finished ( )
virtual

Definition at line 49 of file task_impl.cpp.

Referenced by _notify_finished().

◆ operator=() [1/2]

task_impl& impl::task_impl::operator= ( const task_impl &&  )
privatedelete

◆ operator=() [2/2]

task_impl& impl::task_impl::operator= ( const task_impl )
privatedelete

◆ resume() [1/2]

UTIL_FORCEINLINE int impl::task_impl::resume ( )
inline

Definition at line 108 of file task_impl.h.

References resume().

Referenced by resume().

◆ resume() [2/2]

virtual int impl::task_impl::resume ( void *  priv_data,
EN_TASK_STATUS  expected_status = EN_TS_WAITING 
)
pure virtual

Implemented in task< TCO_MACRO >, and task< TCO_MACRO >.

◆ start() [1/2]

UTIL_FORCEINLINE int impl::task_impl::start ( )
inline

Definition at line 107 of file task_impl.h.

References start().

Referenced by task< TCO_MACRO >::resume(), and start().

◆ start() [2/2]

virtual int impl::task_impl::start ( void *  priv_data,
EN_TASK_STATUS  expected_status = EN_TS_CREATED 
)
pure virtual

Implemented in task< TCO_MACRO >, and task< TCO_MACRO >.

◆ this_task()

LIBCOPP_COTASK_API task_impl * impl::task_impl::this_task ( )
static

get current running task

Returns
current running task or empty pointer

Definition at line 51 of file task_impl.cpp.

References impl::task_impl::ext_coroutine_flag_t::EN_ECFT_COTASK.

Referenced by task< TCO_MACRO >::await_task(), this_task::get_task(), and task< TCO_MACRO >::this_task().

◆ yield() [1/2]

UTIL_FORCEINLINE int impl::task_impl::yield ( )
inline

Definition at line 109 of file task_impl.h.

References yield().

Referenced by task< TCO_MACRO >::await_task(), and yield().

◆ yield() [2/2]

virtual int impl::task_impl::yield ( void **  priv_data)
pure virtual

Implemented in task< TCO_MACRO >, and task< TCO_MACRO >.

Referenced by main().

Field Documentation

◆ action_

action_ptr_type impl::task_impl::action_
private

Definition at line 147 of file task_impl.h.

Referenced by _get_action(), and _set_action().

◆ finish_priv_data_

void* impl::task_impl::finish_priv_data_
protected

Definition at line 151 of file task_impl.h.

Referenced by _notify_finished().

◆ id_

id_type impl::task_impl::id_
private

Definition at line 148 of file task_impl.h.

Referenced by task_impl(), and ~task_impl().

◆ status_

LIBCOPP_COPP_NAMESPACE_ID::util::lock::atomic_int_type<uint32_t> impl::task_impl::status_
private

Definition at line 155 of file task_impl.h.

Referenced by _cas_status().


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