userver: userver/components/single_threaded_task_processors.hpp Source File
Loading...
Searching...
No Matches
single_threaded_task_processors.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/components/single_threaded_task_processors.hpp
4/// @brief @copybrief components::SingleThreadedTaskProcessors
5
6#include <userver/components/component_base.hpp>
7#include <userver/engine/task/single_threaded_task_processors_pool.hpp>
8#include <userver/engine/task/task_processor_fwd.hpp>
9
10#include <memory>
11#include <vector>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace engine {
16struct TaskProcessorConfig;
17} // namespace engine
18
19namespace components {
20
21/// @ingroup userver_components
22///
23/// @brief Component that starts multiple single threaded task processors.
24///
25/// Useful to process tasks in a single threaded third-party libraries
26/// (for example in Python/JS interpreters).
27///
28/// ## Static options:
29/// See "Static task_processor options" at
30/// components::ManagerControllerComponent for options description and
31/// sample.
32class SingleThreadedTaskProcessors final : public ComponentBase {
33public:
34 /// @ingroup userver_component_names
35 /// @brief The default name of components::SingleThreadedTaskProcessors
36 static constexpr std::string_view kName = "single-threaded-task-processors";
37
38 SingleThreadedTaskProcessors(const ComponentConfig& config, const ComponentContext&);
39
40 ~SingleThreadedTaskProcessors() override;
41
42 engine::SingleThreadedTaskProcessorsPool& GetPool() { return pool_; }
43
44 static yaml_config::Schema GetStaticConfigSchema();
45
46private:
47 engine::SingleThreadedTaskProcessorsPool pool_;
48};
49
50template <>
51inline constexpr bool kHasValidate<SingleThreadedTaskProcessors> = true;
52
53} // namespace components
54
55USERVER_NAMESPACE_END