libcopp 2.3.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
9LIBCOPP_COTASK_NAMESPACE_BEGIN
10namespace this_task {
11
16LIBCOPP_COTASK_API impl::task_impl *get_task() LIBCOPP_MACRO_NOEXCEPT;
17
22template <typename Tt>
23LIBCOPP_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
31LIBCOPP_COTASK_NAMESPACE_END
LIBCOPP_COTASK_API_HEAD_ONLY Tt * get()
get current running task and try to convert type
Definition this_task.h:23
LIBCOPP_COTASK_API impl::task_impl * get_task() LIBCOPP_MACRO_NOEXCEPT
get current running task
Definition this_task.cpp:9