26 lines
590 B
C++
26 lines
590 B
C++
#pragma once
|
|
#include "reactor.hpp"
|
|
#include "tcp_connection.hpp"
|
|
#include <thread>
|
|
#include <unordered_map>
|
|
#include <memory>
|
|
|
|
namespace tinyrpc {
|
|
|
|
class IOThread {
|
|
public:
|
|
IOThread();
|
|
~IOThread();
|
|
void addClient(int fd);
|
|
static IOThread* getThisIoThread();
|
|
// void removeFd(int fd);
|
|
Reactor* getReactor() {return m_reactor;}
|
|
private:
|
|
void mainFunc();
|
|
private:
|
|
std::unordered_map<int, std::shared_ptr<TcpConnection>> m_clients;
|
|
std::thread m_thread;
|
|
Reactor* m_reactor{nullptr};
|
|
};
|
|
|
|
} |