userver: userver/engine/task/single_threaded_task_processors_pool.hpp Source File
Loading...
Searching...
No Matches
single_threaded_task_processors_pool.hpp
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include <userver/engine/task/task_processor_fwd.hpp>
7
8USERVER_NAMESPACE_BEGIN
9
10namespace engine {
11
12struct TaskProcessorConfig;
13
14class SingleThreadedTaskProcessorsPool final {
15public:
16 // Do NOT use directly! Use components::SingleThreadedTaskProcessors or for
17 // tests and benchmarks use SingleThreadedTaskProcessorsPool::MakeForTests()
18 explicit SingleThreadedTaskProcessorsPool(const engine::TaskProcessorConfig& config_base);
19 ~SingleThreadedTaskProcessorsPool();
20
21 size_t GetSize() const noexcept { return processors_.size(); }
22 engine::TaskProcessor& At(size_t idx) { return *processors_.at(idx); }
23
24 // For tests and benchmarks only
25 static SingleThreadedTaskProcessorsPool MakeForTests(std::size_t worker_threads);
26
27private:
28 std::vector<std::unique_ptr<engine::TaskProcessor>> processors_;
29};
30
31} // namespace engine
32
33USERVER_NAMESPACE_END