Kagome
Polkadot Runtime Engine in C++17
rpc_thread_pool.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_API_RPC_THREAD_POOL_HPP
7 #define KAGOME_CORE_API_RPC_THREAD_POOL_HPP
8 
9 #include <boost/asio/io_service.hpp>
10 #include <boost/asio/signal_set.hpp>
11 #include <set>
12 #include <thread>
13 
15 #include "log/logger.hpp"
16 
17 namespace kagome::api {
18 
22  class RpcThreadPool : public std::enable_shared_from_this<RpcThreadPool> {
23  public:
25 
26  struct Configuration {
27  size_t min_thread_number = 1;
28  size_t max_thread_number = 10;
29  };
30 
31  RpcThreadPool(std::shared_ptr<Context> context,
32  const Configuration &configuration);
33 
34  ~RpcThreadPool() = default;
35 
39  void start();
40 
44  void stop();
45 
46  private:
47  std::shared_ptr<Context> context_;
49 
50  std::vector<std::shared_ptr<std::thread>> threads_;
51 
52  log::Logger logger_ = log::createLogger("RpcThreadPool", "rpc_transport");
53  };
54 
55 } // namespace kagome::api
56 
57 #endif // KAGOME_CORE_API_RPC_THREAD_POOL_HPP
std::vector< std::shared_ptr< std::thread > > threads_
RpcThreadPool(std::shared_ptr< Context > context, const Configuration &configuration)
std::shared_ptr< Context > context_
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23
Logger createLogger(const std::string &tag)
Definition: logger.cpp:112
const Configuration config_
thread pool for serve RPC calls