From c9e43e1ad5ea3f41e1f7df876460ede167d76351 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 27 Sep 2023 16:25:15 +0200 Subject: prefer to handle cache RPC requests synchronously (#428) * only handle RPC requests in a worker thread if we have an upstream. we may as well handle the request inline on the http_io thread if we're only dealing with local data since the response times should be pretty consistent in that case * http.sys: don't create async worker thread pool until it's needed (typically only if we have an upstream) --- src/zenhttp/httpsys.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/zenhttp/httpsys.h') diff --git a/src/zenhttp/httpsys.h b/src/zenhttp/httpsys.h index 3a2a6065d..d79206082 100644 --- a/src/zenhttp/httpsys.h +++ b/src/zenhttp/httpsys.h @@ -54,7 +54,7 @@ public: virtual void RegisterService(HttpService& Service) override; virtual void Close() override; - WorkerThreadPool& WorkPool() { return m_AsyncWorkPool; } + WorkerThreadPool& WorkPool(); inline bool IsOk() const { return m_IsOk; } inline bool IsAsyncResponseEnabled() const { return m_IsAsyncResponseEnabled; } @@ -80,8 +80,9 @@ private: bool m_IsRequestLoggingEnabled = false; bool m_IsAsyncResponseEnabled = true; - WinIoThreadPool m_ThreadPool; - WorkerThreadPool m_AsyncWorkPool; + WinIoThreadPool m_ThreadPool; + RwLock m_AsyncWorkPoolInitLock; + WorkerThreadPool* m_AsyncWorkPool = nullptr; std::vector m_BaseUris; // eg: http://*:nnnn/ HTTP_SERVER_SESSION_ID m_HttpSessionId = 0; @@ -92,6 +93,7 @@ private: int32_t m_MinPendingRequests = 16; int32_t m_MaxPendingRequests = 128; Event m_ShutdownEvent; + const Config m_InitialConfig; }; } // namespace zen -- cgit v1.2.3