|
libcopp 2.3.1
|
#include <task.h>


Data Structures | |
| struct | task_group |
Public Types | |
| using | macro_coroutine_type = TCO_MACRO |
| using | self_type = task< macro_coroutine_type > |
| using | ptr_type = LIBCOPP_COPP_NAMESPACE_ID::memory::intrusive_ptr< self_type > |
| using | coroutine_type = typename macro_coroutine_type::coroutine_type |
| using | stack_allocator_type = typename macro_coroutine_type::stack_allocator_type |
| using | id_type = typename impl::task_impl::id_type |
| using | id_allocator_type = typename impl::task_impl::id_allocator_type |
| using | macro_coroutine_t = macro_coroutine_type |
| using | self_t = self_type |
| using | ptr_t = ptr_type |
| using | coroutine_t = coroutine_type |
| using | stack_allocator_t = stack_allocator_type |
| using | id_allocator_t = id_allocator_type |
| using | id_t = id_type |
Public Member Functions | |
| task (size_t stack_sz) | |
| constuctor | |
| ptr_type | next (ptr_type next_task, void *priv_data=nullptr) |
| add next task to run when task finished | |
| template<typename Ty > | |
| ptr_type | next (Ty &&functor, void *priv_data=nullptr, size_t stack_size=0, size_t private_buffer_size=0) |
| create next task with functor | |
| template<typename Ty > | |
| ptr_type | next (Ty &&functor, typename coroutine_type::allocator_type &alloc, void *priv_data=nullptr, size_t stack_size=0, size_t private_buffer_size=0) |
| template<typename Ty > | |
| ptr_type | next (Ty(*func)(void *), void *priv_data=nullptr, size_t stack_size=0, size_t private_buffer_size=0) |
| create next task with function | |
| template<typename Ty > | |
| ptr_type | next (Ty(*func)(void *), typename coroutine_type::allocator_type &alloc, void *priv_data=nullptr, size_t stack_size=0, size_t private_buffer_size=0) |
| template<typename Ty , typename TInst > | |
| ptr_type | next (Ty(TInst::*func), TInst *instance, void *priv_data=nullptr, size_t stack_size=0, size_t private_buffer_size=0) |
| create next task with function | |
| template<typename Ty , typename TInst > | |
| ptr_type | next (Ty(TInst::*func), TInst *instance, typename coroutine_type::allocator_type &alloc, void *priv_data=nullptr, size_t stack_size=0, size_t private_buffer_size=0) |
| int | await_task (ptr_type wait_task) |
| await_task another cotask to finish | |
| template<class TAWAITABLE , class TERROR_TRANSFORM , class = LIBCOPP_COPP_NAMESPACE_ID::nostd::enable_if_t<LIBCOPP_COPP_NAMESPACE_ID::stackful_inject_awaitable< LIBCOPP_COPP_NAMESPACE_ID::nostd::remove_cvref_t<TAWAITABLE>>::value>> | |
| LIBCOPP_COPP_NAMESPACE_ID::container_value_type< TAWAITABLE > | await_value (TAWAITABLE &&awaitable, TERROR_TRANSFORM &&error_transform) noexcept(std::is_nothrow_copy_constructible< LIBCOPP_COPP_NAMESPACE_ID::container_value_type< TAWAITABLE > >::value &&noexcept(error_transform(LIBCOPP_COPP_NAMESPACE_ID::COPP_EC_ARGS_ERROR))) |
| Waits for the specified awaitable object to finish and retrieves its result. | |
| template<class TAWAITABLE , class = LIBCOPP_COPP_NAMESPACE_ID::nostd::enable_if_t<LIBCOPP_COPP_NAMESPACE_ID::stackful_inject_awaitable< LIBCOPP_COPP_NAMESPACE_ID::nostd::remove_cvref_t<TAWAITABLE>>::value>> | |
| LIBCOPP_COPP_NAMESPACE_ID::container_value_type< TAWAITABLE > | await_value (TAWAITABLE &&awaitable) noexcept(std::is_nothrow_copy_constructible< LIBCOPP_COPP_NAMESPACE_ID::container_value_type< TAWAITABLE > >::value &&noexcept(LIBCOPP_COPP_NAMESPACE_ID::stackful_channel_error_transform< LIBCOPP_COPP_NAMESPACE_ID::container_value_type< TAWAITABLE > >()(LIBCOPP_COPP_NAMESPACE_ID::COPP_EC_ARGS_ERROR))) |
| Waits for the specified awaitable object to finish and retrieves its result. | |
| template<typename TTask > | |
| int | await_task (TTask *wait_task) |
| await another task | |
| ptr_type | then (ptr_type next_task, void *priv_data=nullptr) |
| add task to run when task finished | |
| template<typename Ty > | |
| ptr_type | then (Ty &&functor, void *priv_data=nullptr) |
| create next task with functor using the same allocator and private buffer size as this task | |
| template<typename Ty > | |
| ptr_type | then (Ty(*func)(void *), void *priv_data=nullptr) |
| virtual | ~task () |
| coroutine_type::ptr_type & | get_coroutine_context () LIBCOPP_MACRO_NOEXCEPT |
| const coroutine_type::ptr_type & | get_coroutine_context () const LIBCOPP_MACRO_NOEXCEPT |
| int | get_ret_code () const override |
| int | start (void *priv_data, EN_TASK_STATUS expected_status=EN_TS_CREATED) override |
| int | resume (void *priv_data, EN_TASK_STATUS expected_status=EN_TS_WAITING) override |
| int | yield (void **priv_data) override |
| int | cancel (void *priv_data) override |
| int | kill (enum EN_TASK_STATUS status, void *priv_data) override |
| bool | is_completed () const LIBCOPP_MACRO_NOEXCEPT override |
| void * | get_private_buffer () |
| size_t | get_private_buffer_size () |
| size_t | use_count () const |
| LIBCOPP_UTIL_FORCEINLINE id_type | get_id () const LIBCOPP_MACRO_NOEXCEPT |
| LIBCOPP_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_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 | |
| LIBCOPP_UTIL_FORCEINLINE int | start () |
| LIBCOPP_UTIL_FORCEINLINE int | resume () |
| LIBCOPP_UTIL_FORCEINLINE int | yield () |
| LIBCOPP_UTIL_FORCEINLINE int | cancel () |
| LIBCOPP_UTIL_FORCEINLINE int | kill (void *priv_data) |
| LIBCOPP_UTIL_FORCEINLINE int | kill (enum EN_TASK_STATUS status) |
| LIBCOPP_UTIL_FORCEINLINE int | kill () |
| virtual LIBCOPP_COTASK_API int | on_finished () |
| LIBCOPP_UTIL_FORCEINLINE action_ptr_type | get_raw_action () const LIBCOPP_MACRO_NOEXCEPT |
| get raw action pointer | |
Static Public Member Functions | |
| template<typename TAct , typename Ty > | |
| static LIBCOPP_COTASK_API_HEAD_ONLY ptr_type | create_with_delegate (Ty &&callable, typename coroutine_type::allocator_type &alloc, size_t stack_size=0, size_t private_buffer_size=0) |
| create task with functor | |
| template<typename Ty > | |
| static ptr_type | create (Ty &&functor, size_t stack_size=0, size_t private_buffer_size=0) |
| create task with functor | |
| template<typename Ty > | |
| static ptr_type | create (Ty &&functor, typename coroutine_type::allocator_type &alloc, size_t stack_size=0, size_t private_buffer_size=0) |
| template<typename Ty > | |
| static ptr_type | create (Ty(*func)(void *), typename coroutine_type::allocator_type &alloc, size_t stack_size=0, size_t private_buffer_size=0) |
| create task with function | |
| template<typename Ty > | |
| static ptr_type | create (Ty(*func)(void *), size_t stack_size=0, size_t private_buffer_size=0) |
| template<typename Ty , typename TInst > | |
| static LIBCOPP_COTASK_API_HEAD_ONLY ptr_type | create (Ty(TInst::*func), TInst *instance, typename coroutine_type::allocator_type &alloc, size_t stack_size=0, size_t private_buffer_size=0) |
| create task with function | |
| template<typename Ty , typename TInst > | |
| static ptr_type | create (Ty(TInst::*func), TInst *instance, size_t stack_size=0, size_t private_buffer_size=0) |
| template<typename Ty , typename... TParams> | |
| static LIBCOPP_COTASK_API_HEAD_ONLY ptr_type | create_with (typename coroutine_type::allocator_type &alloc, size_t stack_size, size_t private_buffer_size, TParams &&...args) |
| create task with functor type and parameters | |
| static self_type * | this_task () |
| static void * | add_buffer_offset (void *in, size_t off) |
| static void * | sub_buffer_offset (void *in, size_t off) |
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) |
Protected Attributes | |
| void * | finish_priv_data_ |
Private Types | |
| using | action_ptr_type = impl::task_impl::action_ptr_type |
| using | action_ptr_t = action_ptr_type |
Private Member Functions | |
| task (const task &)=delete | |
| void | active_next_tasks () |
| int | _notify_finished (void *priv_data) LIBCOPP_MACRO_NOEXCEPT |
Private Attributes | |
| size_t | stack_size_ |
| coroutine_type::ptr_type | coroutine_obj_ |
| task_group | next_list_ |
| void(* | action_destroy_fn_ )(void *) |
| LIBCOPP_COPP_NAMESPACE_ID::util::lock::atomic_int_type< LIBCOPP_COPP_NAMESPACE_ID::util::lock::unsafe_int_type< size_t > > | ref_count_ |
| action_ptr_type | action_ |
| id_type | id_ |
| LIBCOPP_COPP_NAMESPACE_ID::util::lock::atomic_int_type< LIBCOPP_COPP_NAMESPACE_ID::util::lock::unsafe_int_type< uint32_t > > | status_ |
Friends | |
| void | intrusive_ptr_add_ref (self_type *p) |
| void | intrusive_ptr_release (self_type *p) |
|
private |
|
private |
| using task< TCO_MACRO >::coroutine_t = coroutine_type |
| using task< TCO_MACRO >::coroutine_type = typename macro_coroutine_type::coroutine_type |
| using task< TCO_MACRO >::id_allocator_t = id_allocator_type |
| using task< TCO_MACRO >::id_allocator_type = typename impl::task_impl::id_allocator_type |
| using task< TCO_MACRO >::id_type = typename impl::task_impl::id_type |
| using task< TCO_MACRO >::macro_coroutine_t = macro_coroutine_type |
| using task< TCO_MACRO >::macro_coroutine_type = TCO_MACRO |
| using task< TCO_MACRO >::self_type = task<macro_coroutine_type> |
| using task< TCO_MACRO >::stack_allocator_t = stack_allocator_type |
| using task< TCO_MACRO >::stack_allocator_type = typename macro_coroutine_type::stack_allocator_type |
Definition at line 472 of file task.h.
References impl::task_impl::_get_action(), impl::task_impl::_set_action(), EN_TS_CREATED, EN_TS_TIMEOUT, impl::task_impl::get_status(), and impl::task_impl::kill().
|
privatedelete |
|
protectedinherited |
Definition at line 69 of file task_impl.cpp.
References impl::task_impl::status_.
Referenced by task< TCO_MACRO >::cancel(), task< TCO_MACRO >::kill(), and task< TCO_MACRO >::start().
|
protectedinherited |
Definition at line 67 of file task_impl.cpp.
References impl::task_impl::action_.
Referenced by impl::task_impl::_notify_finished(), and task< TCO_MACRO >::~task().
|
inlineprivate |
Definition at line 800 of file task.h.
References impl::task_impl::_notify_finished().
|
protectedinherited |
Definition at line 65 of file task_impl.cpp.
References impl::task_impl::action_.
Referenced by task< TCO_MACRO >::~task().
|
inlineprivate |
Definition at line 744 of file task.h.
References EN_TS_INVALID, and EN_TS_RUNNING.
|
inlinestatic |
|
inline |
await_task another cotask to finish
| wait_task | which stack to wait for |
Definition at line 327 of file task.h.
References impl::task_impl::is_exiting(), impl::task_impl::this_task(), and impl::task_impl::yield().
|
inline |
|
inlinenoexcept |
Waits for the specified awaitable object to finish and retrieves its result.
| awaitable | The awaitable object to be consumed. |
|
inlinenoexcept |
Waits for the specified awaitable object to finish and retrieves its result.
| awaitable | The awaitable object to be consumed. |
| error_transform | A callable object used to transform error code to return type if any occur. |
|
inlineinherited |
Definition at line 112 of file task_impl.h.
References impl::task_impl::cancel().
Referenced by impl::task_impl::cancel().
|
inlineoverridevirtual |
Implements impl::task_impl.
Definition at line 627 of file task.h.
References impl::task_impl::_cas_status(), impl::task_impl::_notify_finished(), EN_TS_CANCELED, EN_TS_RUNNING, impl::task_impl::get_status(), and LIBCOPP_UTIL_LIKELY_CONDITION.
|
inlinestatic |
|
inlinestatic |
create task with functor
| action | |
| stack_size | stack size |
| private_buffer_size | buffer size to store private data |
Definition at line 92 of file task.h.
References impl::task_impl::ext_coroutine_flag_t::EN_ECFT_COTASK, and get_placement_destroy().
|
inline |
|
inline |
|
inlineinherited |
Definition at line 76 of file task_impl.h.
Referenced by task_manager< task< TCO_MACRO > >::add_task(), and main().
|
inline |
|
inline |
|
inlineinherited |
get raw action pointer
Definition at line 134 of file task_impl.h.
|
inlineoverridevirtual |
Implements impl::task_impl.
|
inlineinherited |
get task status
Definition at line 82 of file task_impl.h.
Referenced by task< TCO_MACRO >::cancel(), impl::task_impl::is_canceled(), impl::task_impl::is_exiting(), impl::task_impl::is_faulted(), impl::task_impl::is_timeout(), task< TCO_MACRO >::kill(), and task< TCO_MACRO >::~task().
|
virtualinherited |
Definition at line 39 of file task_impl.cpp.
References EN_TS_CANCELED, and impl::task_impl::get_status().
|
inlineoverridevirtual |
Reimplemented from impl::task_impl.
|
inherited |
check if a cotask is exiting
Definition at line 47 of file task_impl.cpp.
References EN_TS_DONE, and impl::task_impl::get_status().
Referenced by task_manager< task< TCO_MACRO > >::add_task(), task< TCO_MACRO >::await_task(), impl::task_impl::is_completed(), and task< TCO_MACRO >::next().
|
virtualinherited |
Definition at line 43 of file task_impl.cpp.
References EN_TS_KILLED, and impl::task_impl::get_status().
|
virtualinherited |
Definition at line 45 of file task_impl.cpp.
References EN_TS_TIMEOUT, and impl::task_impl::get_status().
|
inlineinherited |
Definition at line 114 of file task_impl.h.
References impl::task_impl::kill().
Referenced by impl::task_impl::kill(), and task< TCO_MACRO >::~task().
|
inlineinherited |
Definition at line 113 of file task_impl.h.
References impl::task_impl::kill().
Referenced by impl::task_impl::kill().
|
inlineoverridevirtual |
Implements impl::task_impl.
Definition at line 661 of file task.h.
References impl::task_impl::_cas_status(), impl::task_impl::_notify_finished(), EN_TS_RUNNING, impl::task_impl::get_status(), and LIBCOPP_UTIL_LIKELY_CONDITION.
Referenced by main().
|
inlineinherited |
Definition at line 107 of file task_impl.h.
References EN_TS_KILLED, and impl::task_impl::kill().
Referenced by impl::task_impl::kill().
|
inline |
add next task to run when task finished
| next_task | next stack |
| priv_data | priv_data passed to resume or start next stack |
Definition at line 232 of file task.h.
References EN_TS_CREATED, EN_TS_WAITING, impl::task_impl::is_completed(), and impl::task_impl::is_exiting().
|
virtualinherited |
Definition at line 49 of file task_impl.cpp.
Referenced by impl::task_impl::_notify_finished().
|
inlineinherited |
Definition at line 110 of file task_impl.h.
References impl::task_impl::resume().
Referenced by impl::task_impl::resume().
|
inlineoverridevirtual |
Implements impl::task_impl.
Definition at line 604 of file task.h.
References impl::task_impl::start().
Referenced by main().
|
inlineinherited |
Definition at line 109 of file task_impl.h.
References impl::task_impl::start().
Referenced by task< TCO_MACRO >::resume(), and impl::task_impl::start().
|
inlineoverridevirtual |
Implements impl::task_impl.
Definition at line 523 of file task.h.
References impl::task_impl::_cas_status(), impl::task_impl::_notify_finished(), EN_TS_DONE, EN_TS_RUNNING, EN_TS_WAITING, impl::task_impl::is_completed(), LIBCOPP_UTIL_LIKELY_CONDITION, and LIBCOPP_UTIL_UNLIKELY_CONDITION.
Referenced by main().
|
inlinestatic |
|
inline |
add task to run when task finished
| next_task | then stack |
| priv_data | priv_data passed to resume or start the stack |
|
inlinestatic |
get current running task and convert to task object
Definition at line 463 of file task.h.
References impl::task_impl::this_task().
|
inline |
|
inlineinherited |
Definition at line 111 of file task_impl.h.
References impl::task_impl::yield().
Referenced by task< TCO_MACRO >::await_task(), and impl::task_impl::yield().
|
inlineoverridevirtual |
Implements impl::task_impl.
|
friend |
|
friend |
|
privateinherited |
Definition at line 149 of file task_impl.h.
Referenced by impl::task_impl::_get_action(), and impl::task_impl::_set_action().
|
private |
|
private |
|
protectedinherited |
Definition at line 153 of file task_impl.h.
Referenced by impl::task_impl::_notify_finished().
|
privateinherited |
Definition at line 150 of file task_impl.h.
Referenced by impl::task_impl::task_impl(), and impl::task_impl::~task_impl().
|
private |
|
private |
|
private |
|
privateinherited |
Definition at line 161 of file task_impl.h.
Referenced by impl::task_impl::_cas_status().