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/loggable_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/// Usefull 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 LoggableComponentBase {
33 public:
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,
39 const ComponentContext&);
40
41 ~SingleThreadedTaskProcessors() override;
42
43 engine::SingleThreadedTaskProcessorsPool& GetPool() { return pool_; }
44
45 static yaml_config::Schema GetStaticConfigSchema();
46
47 private:
48 engine::SingleThreadedTaskProcessorsPool pool_;
49};
50
51template <>
52inline constexpr bool kHasValidate<SingleThreadedTaskProcessors> = true;
53
54} // namespace components
55
56USERVER_NAMESPACE_END