userver: userver/engine/task/current_task.hpp Source File
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
11USERVER_NAMESPACE_BEGIN
12
13namespace engine::ev {
14class ThreadControl;
15} // namespace engine::ev
16
17namespace engine {
18
19/// @brief Namespace with functions to work with current task from within it
20namespace current_task {
21
22/// Returns true only when running in userver coroutine environment,
23/// i.e. in an engine::TaskProcessor thread.
24bool IsTaskProcessorThread() noexcept;
25
26/// Returns reference to the task processor executing the caller
28
29/// Returns task coroutine stack size
30std::size_t GetStackSize();
31
32/// @cond
33// Returns ev thread handle, internal use only
34ev::ThreadControl& GetEventThread();
35/// @endcond
36
37} // namespace current_task
38
39namespace impl {
40
41// For internal use only.
42std::uint64_t GetCreatedTaskCount(TaskProcessor&);
43
44} // namespace impl
45
46} // namespace engine
47
48USERVER_NAMESPACE_END