userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
current_task.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/engine/task/current_task.hpp
4
/// @brief Utility functions that query and operate on the current task
5
6
#
include
<
cstddef
>
7
#
include
<
cstdint
>
8
9
#
include
<
userver
/
engine
/
task
/
task_processor_fwd
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
engine::ev {
14
class
ThreadControl;
15
}
// namespace engine::ev
16
17
namespace
engine {
18
19
class
Deadline;
20
21
/// @brief Namespace with functions to work with current task from within it
22
namespace
current_task
{
23
24
/// Returns true only when running in userver coroutine environment,
25
/// i.e. in an engine::TaskProcessor thread.
26
bool
IsTaskProcessorThread
()
noexcept
;
27
28
/// Returns reference to the task processor executing the caller
29
TaskProcessor&
GetTaskProcessor
();
30
31
/// @brief Get the number of worker threads in the current task processor.
32
///
33
/// The value is configured with the `task_processors.*NAME*.worker_threads`
34
/// static option of @ref components::ManagerControllerComponent.
35
///
36
/// @see @ref engine::GetWorkerCount
37
std::size_t
GetWorkerCount
();
38
39
/// Returns reference to the blocking task processor
40
TaskProcessor&
GetBlockingTaskProcessor
();
41
42
/// Returns task coroutine stack size
43
std::size_t
GetStackSize
();
44
45
/// @cond
46
// Returns ev thread handle, internal use only
47
ev::ThreadControl& GetEventThread();
48
/// @endcond
49
50
namespace
impl {
51
52
// For internal use only.
53
void
* GetRawCurrentTaskContext()
noexcept
;
54
55
// For internal use only.
56
bool
IsCritical();
57
58
// Note: an actually useful deadline should be acquired from server::request::GetTaskInheritedDeadline.
59
// For internal use only.
60
Deadline GetDeadline()
noexcept
;
61
62
}
// namespace impl
63
64
}
// namespace current_task
65
66
namespace
impl
{
67
68
// For internal use only.
69
std::uint64_t GetCreatedTaskCount(TaskProcessor&);
70
71
}
// namespace impl
72
73
}
// namespace engine
74
75
USERVER_NAMESPACE_END
userver
engine
task
current_task.hpp
Generated on
for userver by
Doxygen
1.17.0