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

#include <task_impl.h>

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

Data Structures

struct  ext_coroutine_flag_t

Public Member Functions

 task_impl ()
virtual ~task_impl ()=0
virtual bool is_canceled () const UTIL_CONFIG_NOEXCEPT
virtual bool is_completed () const UTIL_CONFIG_NOEXCEPT
virtual bool is_faulted () const UTIL_CONFIG_NOEXCEPT
virtual bool is_timeout () const UTIL_CONFIG_NOEXCEPT
bool is_exiting () const UTIL_CONFIG_NOEXCEPT
 check if a cotask is exiting More...
virtual 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
int kill (void *priv_data)
int start ()
int resume ()
int yield ()
int cancel ()
int kill (enum EN_TASK_STATUS status)
int kill ()
virtual int on_finished ()
action_ptr_t get_raw_action () const UTIL_CONFIG_NOEXCEPT
 get raw action pointer More...

Static Public Member Functions

static task_implthis_task ()

Protected Types

typedef task_action_implaction_ptr_t

Protected Member Functions

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

Protected Attributes

void * finish_priv_data_

Private Member Functions

 task_impl (const task_impl &)

Private Attributes

action_ptr_t action_
::util::lock::atomic_int_type< uint32_t > status_

Detailed Description

Definition at line 41 of file task_impl.h.

Member Typedef Documentation

Definition at line 43 of file task_impl.h.

Constructor & Destructor Documentation

cotask::impl::task_impl::task_impl ( const task_impl )
cotask::impl::task_impl::task_impl ( )

Definition at line 22 of file task_impl.cpp.

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

Definition at line 24 of file task_impl.cpp.

References cotask::EN_TS_DONE.

Member Function Documentation

bool cotask::impl::task_impl::_cas_status ( EN_TASK_STATUS expected,
EN_TASK_STATUS  desired 
task_impl::action_ptr_t cotask::impl::task_impl::_get_action ( )

Definition at line 53 of file task_impl.cpp.

References action_.

Referenced by _notify_finished(), and get_raw_action().

int cotask::impl::task_impl::_notify_finished ( void *  priv_data)
void cotask::impl::task_impl::_set_action ( action_ptr_t  action)

Definition at line 51 of file task_impl.cpp.

References print_color::action, and action_.

Referenced by get_raw_action().

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

Definition at line 94 of file task_impl.h.

References cancel().

Referenced by cancel(), get_status(), and cotask::task< TCO_MACRO, TTASK_MACRO >::kill().

action_ptr_t cotask::impl::task_impl::get_raw_action ( ) const

get raw action pointer

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

Definition at line 111 of file task_impl.h.

References _cas_status(), _get_action(), _notify_finished(), _set_action(), print_color::action, and action_.

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

Implemented in cotask::task< TCO_MACRO, TTASK_MACRO >.

Referenced by get_status().

EN_TASK_STATUS cotask::impl::task_impl::get_status ( ) const
bool cotask::impl::task_impl::is_canceled ( ) const

Definition at line 26 of file task_impl.cpp.

References cotask::EN_TS_CANCELED, and get_status().

Referenced by get_status().

bool cotask::impl::task_impl::is_completed ( ) const

Reimplemented in cotask::task< TCO_MACRO, TTASK_MACRO >.

Definition at line 28 of file task_impl.cpp.

References is_exiting().

Referenced by get_status().

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

check if a cotask is exiting

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
return true if a cotask is exiting.

Definition at line 34 of file task_impl.cpp.

References cotask::EN_TS_DONE, and get_status().

Referenced by cotask::task< TCO_MACRO, TTASK_MACRO >::await(), get_status(), is_completed(), and cotask::task< TCO_MACRO, TTASK_MACRO >::next().

bool cotask::impl::task_impl::is_faulted ( ) const

Definition at line 30 of file task_impl.cpp.

References cotask::EN_TS_KILLED, and get_status().

Referenced by get_status().

bool cotask::impl::task_impl::is_timeout ( ) const

Definition at line 32 of file task_impl.cpp.

References cotask::EN_TS_TIMEOUT, and get_status().

Referenced by get_status().

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

Definition at line 89 of file task_impl.h.

References cotask::EN_TS_KILLED, and kill().

Referenced by kill().

int cotask::impl::task_impl::kill ( enum EN_TASK_STATUS  status)

Definition at line 95 of file task_impl.h.

References kill().

Referenced by kill().

int cotask::impl::task_impl::kill ( )
int cotask::impl::task_impl::on_finished ( )

Definition at line 36 of file task_impl.cpp.

Referenced by _notify_finished(), and kill().

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

Definition at line 92 of file task_impl.h.

References resume().

Referenced by get_status(), cotask::task< TCO_MACRO, TTASK_MACRO >::kill(), and resume().

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

Implemented in cotask::task< TCO_MACRO, TTASK_MACRO >.

Referenced by main().

int cotask::impl::task_impl::yield ( )

Field Documentation

action_ptr_t cotask::impl::task_impl::action_

Definition at line 122 of file task_impl.h.

Referenced by _get_action(), _set_action(), and get_raw_action().

void* cotask::impl::task_impl::finish_priv_data_
::util::lock::atomic_int_type<uint32_t> cotask::impl::task_impl::status_

Definition at line 129 of file task_impl.h.

Referenced by _cas_status(), and get_status().

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