Add multi-thread support.

This commit is contained in:
flamingcow
2019-05-04 12:16:31 -07:00
parent 95e9eb0c51
commit e7b2f089f3
4 changed files with 53 additions and 35 deletions

View File

@@ -8,14 +8,16 @@
class FastCGIServer {
public:
FastCGIServer(int port, const std::function<void(std::unique_ptr<FastCGIRequest>)>& callback, const std::unordered_set<std::string_view>& headers={});
FastCGIServer(int port, const std::function<void(std::unique_ptr<FastCGIRequest>)>& callback, int threads=1, const std::unordered_set<std::string_view>& headers={});
void Serve();
private:
void NewConn();
void NewConn(int listen_sock, int epoll_fd);
int NewListenSock();
void ServeInt();
const int port_;
const std::function<void(std::unique_ptr<FastCGIRequest>)> callback_;
const int threads_;
const std::unordered_set<std::string_view> headers_;
int epoll_fd_;
int listen_sock_;
};