libcopp
2.2.0
|
task manager for stackful coroutine task More...
#include <task_manager.h>
Data Structures | |
struct | flag_guard_type |
struct | flag_type |
Public Types | |
using | task_type = task< TCO_MACRO > |
using | container_type = std::unordered_map< typename task_type::id_type, detail::task_manager_node< task_type > > |
using | id_type = typename task_type::id_type |
using | task_ptr_type = typename task_type::ptr_type |
using | self_type = task_manager< task_type > |
using | ptr_type = std::shared_ptr< self_type > |
using | id_t = id_type |
using | self_t = self_type |
using | task_t = task_type |
using | task_ptr_t = task_ptr_type |
using | ptr_t = ptr_type |
using | container_t = container_type |
using | flag_t = flag_type |
Public Member Functions | |
task_manager () | |
~task_manager () | |
void | reset () |
int | add_task (const task_ptr_type &task, time_t timeout_sec, int timeout_nsec) |
add task to manager please make the task has method of get_id() and will return a unique id More... | |
int | add_task (const task_ptr_type &task) |
add task to manager please make the task has method of get_id() and will return a unique id More... | |
int | set_timeout (id_type id, time_t timeout_sec, int timeout_nsec) |
set or update task timeout More... | |
int | remove_task (id_type id, const task_ptr_type &confirm_ptr) |
remove task in this manager More... | |
int | remove_task (id_type id) |
remove task in this manager More... | |
int | remove_task (id_type id, const task_type *confirm_ptr) |
remove task in this manager More... | |
task_ptr_type | find_task (id_type id) |
find task by id More... | |
int | start (id_type id, void *priv_data=nullptr) |
int | resume (id_type id, void *priv_data=nullptr) |
int | cancel (id_type id, void *priv_data=nullptr) |
int | kill (id_type id, enum EN_TASK_STATUS status, void *priv_data=nullptr) |
int | kill (id_type id, void *priv_data=nullptr) |
int | tick (time_t sec, int nsec=0) |
active tick event and deal with clock More... | |
size_t | get_tick_checkpoint_size () const LIBCOPP_MACRO_NOEXCEPT |
get timeout checkpoint number in this manager More... | |
size_t | get_task_size () const LIBCOPP_MACRO_NOEXCEPT |
get task number in this manager More... | |
detail::tickspec_t | get_last_tick_time () const LIBCOPP_MACRO_NOEXCEPT |
get last tick time More... | |
const container_type & | get_container () const LIBCOPP_MACRO_NOEXCEPT |
task container, this api is just used for provide information to users More... | |
const std::set< detail::task_timer_node< id_type > > & | get_checkpoints () const LIBCOPP_MACRO_NOEXCEPT |
get all task checkpoints, this api is just used for provide information to users More... | |
Static Public Member Functions | |
static ptr_type | create () |
create a new task manager More... | |
Private Member Functions | |
void | set_timeout_timer (detail::task_manager_node< task_type > &node, time_t timeout_sec, int timeout_nsec) |
void | remove_timeout_timer (detail::task_manager_node< task_type > &node) |
Private Attributes | |
container_type | tasks_ |
detail::tickspec_t | last_tick_time_ |
std::set< detail::task_timer_node< id_type > > | task_timeout_timer_ |
LIBCOPP_COPP_NAMESPACE_ID::util::lock::spin_lock | action_lock_ |
int | flags_ |
task manager for stackful coroutine task
Definition at line 159 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::container_t = container_type |
Definition at line 182 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::container_type = std::unordered_map<typename task_type::id_type, detail::task_manager_node<task_type> > |
Definition at line 162 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::flag_t = flag_type |
Definition at line 183 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::id_t = id_type |
Definition at line 177 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::id_type = typename task_type::id_type |
Definition at line 163 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::ptr_t = ptr_type |
Definition at line 181 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::ptr_type = std::shared_ptr<self_type> |
Definition at line 166 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::self_t = self_type |
Definition at line 178 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::self_type = task_manager<task_type> |
Definition at line 165 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::task_ptr_t = task_ptr_type |
Definition at line 180 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::task_ptr_type = typename task_type::ptr_type |
Definition at line 164 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::task_t = task_type |
Definition at line 179 of file task_manager.h.
using task_manager< task< TCO_MACRO > >::task_type = task<TCO_MACRO> |
Definition at line 161 of file task_manager.h.
|
inline |
Definition at line 207 of file task_manager.h.
|
inline |
Definition at line 212 of file task_manager.h.
|
inline |
add task to manager please make the task has method of get_id() and will return a unique id
task | task to be inserted |
Definition at line 335 of file task_manager.h.
References add_task().
Referenced by add_task().
|
inline |
add task to manager please make the task has method of get_id() and will return a unique id
task | task to be inserted |
timeout_sec | timeout in second ( unix time stamp recommanded ) |
timeout_nsec | timeout in nanosecond ( must be in the range 0-999999999 ) |
Definition at line 270 of file task_manager.h.
References COPP_EC_ALREADY_EXIST, COPP_EC_ARGS_ERROR, COPP_EC_CAST_FAILED, COPP_EC_EXTERNAL_INSERT_FAILED, COPP_EC_IN_RESET, COPP_EC_SUCCESS, COPP_EC_TASK_ALREADY_IN_ANOTHER_MANAGER, COPP_EC_TASK_IS_EXITING, impl::task_impl::get_id(), and impl::task_impl::is_exiting().
|
inline |
Definition at line 570 of file task_manager.h.
References COPP_EC_IN_RESET, and COPP_EC_NOT_FOUND.
|
inlinestatic |
create a new task manager
Definition at line 255 of file task_manager.h.
|
inline |
find task by id
id | task id |
Definition at line 442 of file task_manager.h.
|
inline |
get all task checkpoints, this api is just used for provide information to users
Definition at line 813 of file task_manager.h.
|
inline |
task container, this api is just used for provide information to users
Definition at line 807 of file task_manager.h.
|
inline |
|
inline |
|
inline |
get timeout checkpoint number in this manager
Definition at line 789 of file task_manager.h.
|
inline |
Definition at line 623 of file task_manager.h.
References COPP_EC_IN_RESET, and COPP_EC_NOT_FOUND.
|
inline |
Definition at line 665 of file task_manager.h.
References EN_TS_KILLED, and kill().
Referenced by kill().
|
inline |
remove task in this manager
id | task id |
Definition at line 385 of file task_manager.h.
References remove_task().
Referenced by remove_task().
|
inline |
remove task in this manager
id | task id |
confirm_ptr | check task ptr before just remove by id |
Definition at line 378 of file task_manager.h.
References remove_task().
Referenced by remove_task().
|
inline |
remove task in this manager
id | task id |
confirm_ptr | check task ptr before just remove by id |
Definition at line 393 of file task_manager.h.
References COPP_EC_IN_RESET, COPP_EC_NOT_FOUND, COPP_EC_SUCCESS, EN_TS_CREATED, EN_TS_DONE, and EN_TS_KILLED.
|
inlineprivate |
Definition at line 841 of file task_manager.h.
|
inline |
Definition at line 217 of file task_manager.h.
References EN_TS_KILLED.
|
inline |
Definition at line 521 of file task_manager.h.
References COPP_EC_IN_RESET, COPP_EC_NOT_FOUND, and EN_TS_DONE.
|
inline |
set or update task timeout
id | task id of which should be already added into this manager |
timeout_sec | timeout in second ( unix time stamp recommanded ) |
timeout_nsec | timeout in nanosecond ( must be in the range 0-999999999 ) |
Definition at line 351 of file task_manager.h.
References COPP_EC_IN_RESET, COPP_EC_NOT_FOUND, and COPP_EC_SUCCESS.
|
inlineprivate |
Definition at line 818 of file task_manager.h.
References detail::task_timer_node< TTASK_ID_TYPE >::expired_time, detail::task_timer_node< TTASK_ID_TYPE >::task_id, detail::tickspec_t::tv_nsec, and detail::tickspec_t::tv_sec.
|
inline |
Definition at line 472 of file task_manager.h.
References COPP_EC_IN_RESET, COPP_EC_NOT_FOUND, and EN_TS_DONE.
|
inline |
active tick event and deal with clock
sec | current time in second ( unix time stamp recommanded ) |
nsec | current time in nanosecond ( must be in the range 0-999999999 ) |
Definition at line 675 of file task_manager.h.
References COPP_EC_IN_RESET, COPP_EC_SUCCESS, EN_TS_TIMEOUT, detail::task_timer_node< TTASK_ID_TYPE >::expired_time, detail::tickspec_t::tv_nsec, and detail::tickspec_t::tv_sec.
|
private |
Definition at line 864 of file task_manager.h.
|
private |
Definition at line 866 of file task_manager.h.
|
private |
Definition at line 860 of file task_manager.h.
|
private |
Definition at line 861 of file task_manager.h.
|
private |
Definition at line 859 of file task_manager.h.