From 565f08ec3327c6cdad2eeb2fac1f45a1a24b95cf Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Thu, 9 Sep 2021 13:58:37 +0200 Subject: Made HttpServer an abstract interface, and moved remaining implementation specifics for http.sys into the dedicated cpp/h source files --- zencore/httpsys.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'zencore/httpsys.h') diff --git a/zencore/httpsys.h b/zencore/httpsys.h index 8a7b372dd..7c0543e45 100644 --- a/zencore/httpsys.h +++ b/zencore/httpsys.h @@ -13,25 +13,28 @@ namespace zen { /** * @brief Windows implementation of HTTP server based on http.sys - * + * * This requires elevation to function */ -class HttpSysServer +class HttpSysServer : public HttpServer { friend class HttpSysTransaction; public: - HttpSysServer(WinIoThreadPool& InThreadPool); + explicit HttpSysServer(int ThreadCount); ~HttpSysServer(); - void Initialize(const wchar_t* UrlPath); - void Run(bool TestMode); + // HttpServer interface implementation - void RequestExit() { m_ShutdownEvent.Set(); } + virtual void Initialize(int BasePort) override; + virtual void Run(bool TestMode) override; + virtual void RequestExit() override; + virtual void AddEndpoint(HttpService& Service) override; - void StartServer(); - void StopServer(); +private: + void Initialize(const wchar_t* UrlPath); + void StartServer(); void OnHandlingRequest(); void IssueNewRequestMaybe(); @@ -41,18 +44,18 @@ public: void RemoveEndpoint(const char* Endpoint, HttpService& Service); private: - bool m_IsOk = false; - bool m_IsHttpInitialized = false; - WinIoThreadPool& m_ThreadPool; + bool m_IsOk = false; + bool m_IsHttpInitialized = false; + WinIoThreadPool m_ThreadPool; std::wstring m_BaseUri; // http://*:nnnn/ HTTP_SERVER_SESSION_ID m_HttpSessionId = 0; HTTP_URL_GROUP_ID m_HttpUrlGroupId = 0; HANDLE m_RequestQueueHandle = 0; std::atomic_int32_t m_PendingRequests{0}; - int32_t m_MinPendingRequests = 4; - int32_t m_MaxPendingRequests = 32; + int32_t m_MinPendingRequests = 16; + int32_t m_MaxPendingRequests = 128; Event m_ShutdownEvent; }; -} +} // namespace zen -- cgit v1.2.3