aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpsys.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenhttp/httpsys.cpp')
-rw-r--r--src/zenhttp/httpsys.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/zenhttp/httpsys.cpp b/src/zenhttp/httpsys.cpp
index f95a31914..886d53143 100644
--- a/src/zenhttp/httpsys.cpp
+++ b/src/zenhttp/httpsys.cpp
@@ -747,7 +747,7 @@ HttpSysServer::HttpSysServer(const Config& Config)
, m_IsRequestLoggingEnabled(Config.IsRequestLoggingEnabled)
, m_IsAsyncResponseEnabled(Config.IsAsyncResponseEnabled)
, m_ThreadPool(Config.ThreadCount != 0 ? Config.ThreadCount : std::thread::hardware_concurrency())
-, m_AsyncWorkPool(Config.AsyncWorkThreadCount != 0 ? Config.AsyncWorkThreadCount : 16, "http_async")
+, m_InitialConfig(Config)
{
ULONG Result = HttpInitialize(HTTPAPI_VERSION_2, HTTP_INITIALIZE_SERVER, nullptr);
@@ -768,6 +768,9 @@ HttpSysServer::~HttpSysServer()
{
ZEN_ERROR("~HttpSysServer() called without calling Close() first");
}
+
+ delete m_AsyncWorkPool;
+ m_AsyncWorkPool = nullptr;
}
void
@@ -977,6 +980,24 @@ HttpSysServer::Cleanup()
}
}
+WorkerThreadPool&
+HttpSysServer::WorkPool()
+{
+ if (!m_AsyncWorkPool)
+ {
+ RwLock::ExclusiveLockScope _(m_AsyncWorkPoolInitLock);
+
+ if (!m_AsyncWorkPool)
+ {
+ unsigned int WorkerThreadCount = m_InitialConfig.AsyncWorkThreadCount != 0 ? m_InitialConfig.AsyncWorkThreadCount : 16;
+
+ m_AsyncWorkPool = new WorkerThreadPool(WorkerThreadCount, "http_async");
+ }
+ }
+
+ return *m_AsyncWorkPool;
+}
+
void
HttpSysServer::StartServer()
{