userver: userver/storages/redis/impl/thread_pools.hpp Source File
Loading...
Searching...
No Matches
thread_pools.hpp
1#pragma once
2
3#include <memory>
4
5USERVER_NAMESPACE_BEGIN
6
7namespace engine::ev {
8class ThreadPool;
9} // namespace engine::ev
10
11namespace redis {
12
13class ThreadPools {
14 public:
15 ThreadPools(size_t sentinel_thread_pool_size, size_t redis_thread_pool_size);
16 ~ThreadPools();
17
18 engine::ev::ThreadPool& GetSentinelThreadPool() const;
19 const std::shared_ptr<engine::ev::ThreadPool>& GetRedisThreadPool() const;
20
21 private:
22 // Sentinel and Redis should use separate thread pools to avoid deadlocks.
23 // Sentinel waits synchronously while Redis starts and stops watchers in
24 // Connect()/Disconnect().
25 std::unique_ptr<engine::ev::ThreadPool> sentinel_thread_pool_;
26 std::shared_ptr<engine::ev::ThreadPool> redis_thread_pool_;
27};
28
29} // namespace redis
30
31USERVER_NAMESPACE_END