libcopp  2.2.0
this_task.h
Go to the documentation of this file.
1 // Copyright 2023 owent
2 
3 #pragma once
4 
5 #include <libcopp/utils/config/libcopp_build_features.h>
6 
8 
9 LIBCOPP_COTASK_NAMESPACE_BEGIN
10 namespace this_task {
11 
16 LIBCOPP_COTASK_API impl::task_impl *get_task() LIBCOPP_MACRO_NOEXCEPT;
17 
22 template <typename Tt>
23 LIBCOPP_COTASK_API_HEAD_ONLY Tt *get() {
24 #if defined(LIBCOPP_MACRO_ENABLE_RTTI) && LIBCOPP_MACRO_ENABLE_RTTI
25  return dynamic_cast<Tt *>(get_task());
26 #else
27  return static_cast<Tt *>(get_task());
28 #endif
29 }
30 } // namespace this_task
31 LIBCOPP_COTASK_NAMESPACE_END
LIBCOPP_COTASK_API impl::task_impl * get_task() LIBCOPP_MACRO_NOEXCEPT
get current running task
Definition: this_task.cpp:9
LIBCOPP_COTASK_API_HEAD_ONLY Tt * get()
get current running task and try to convert type
Definition: this_task.h:23