userver: userver/engine/task/task_processor_fwd.hpp Source File
Loading...
Searching...
No Matches
task_processor_fwd.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <functional>
5
6/// @file userver/engine/task/task_processor_fwd.hpp
7/// @brief Manages tasks execution on OS threads.
8
9USERVER_NAMESPACE_BEGIN
10
11/// Asynchronous engine primitives
12namespace engine {
13
14/// @class engine::TaskProcessor
15/// @brief Manages tasks execution on OS threads.
16///
17/// To create a task processor add its configuration to the "task_processors"
18/// section of the components::ManagerControllerComponent static configuration.
19class TaskProcessor;
20
21/// @brief Get approximate count of ready-to-run tasks on the `task_processor`
22std::size_t GetQueueSize(const TaskProcessor& task_processor) noexcept;
23
24/// @brief Get the number of worker threads in `task_processor`.
25///
26/// The value is configured with the `task_processors.*NAME*.worker_threads`
27/// static option of @ref components::ManagerControllerComponent.
28///
29/// @see @ref engine::current_task::GetWorkerCount
30std::size_t GetWorkerCount(const TaskProcessor& task_processor) noexcept;
31
32/// @brief Register a function that runs on all threads on task processor
33/// creation. Used for pre-initializing thread_local variables with heavy
34/// constructors (constructor that does blocking system calls, file access,
35/// ...):
36///
37/// @note It is a low-level function. You might not want to use it.
38void RegisterThreadStartedHook(std::function<void()>);
39
40} // namespace engine
41
42USERVER_NAMESPACE_END