#pragma once #include "reactor.hpp" #include "tcp_connection.hpp" #include #include #include #include #include namespace tinyrpc { class TcpServer; class IOThread { friend class IOThreadPool; public: void addClient(TcpServer* ser, int fd); static IOThread* getThisIoThread(); // void removeFd(int fd); Reactor* getReactor() {return m_reactor;} private: IOThread(); ~IOThread(); void mainFunc(); private: std::unordered_map> m_clients; std::thread m_thread; Reactor* m_reactor{nullptr}; }; class IOThreadPool { public: IOThreadPool(int size); IOThread* getIOThread(); ~IOThreadPool(); private: std::mutex m_mtx; int m_idx {-1}; const std::vector m_IOThreads{}; }; }