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 {
15 public:
16 // Do NOT use directly! Use components::SingleThreadedTaskProcessors or for
17 // tests and benchmarks use SingleThreadedTaskProcessorsPool::MakeForTests()
18 explicit SingleThreadedTaskProcessorsPool(
19 const engine::TaskProcessorConfig& config_base);
20 ~SingleThreadedTaskProcessorsPool();
21
22 size_t GetSize() const noexcept { return processors_.size(); }
23 engine::TaskProcessor& At(size_t idx) { return *processors_.at(idx); }
24
25 // For tests and benchmarks only
26 static SingleThreadedTaskProcessorsPool MakeForTests(
27 std::size_t worker_threads);
28
29 private:
30 std::vector<std::unique_ptr<engine::TaskProcessor>> processors_;
31};
32
33} // namespace engine
34
35USERVER_NAMESPACE_END