diff options
| author | Stefan Boberg <[email protected]> | 2021-09-09 15:14:08 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-09 15:14:08 +0200 |
| commit | 6ec26c46d694a1d5291790a9c70bec25dce4b513 (patch) | |
| tree | 4177d45f9703d11f00e495f0fde77f4445453d2d /zenhttp/iothreadpool.cpp | |
| parent | HttpServer::AddEndpoint -> HttpServer::RegisterService (diff) | |
| download | zen-6ec26c46d694a1d5291790a9c70bec25dce4b513.tar.xz zen-6ec26c46d694a1d5291790a9c70bec25dce4b513.zip | |
Factored out http server related code into zenhttp module since it feels out of place in zencore
Diffstat (limited to 'zenhttp/iothreadpool.cpp')
| -rw-r--r-- | zenhttp/iothreadpool.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/zenhttp/iothreadpool.cpp b/zenhttp/iothreadpool.cpp new file mode 100644 index 000000000..4ed81d7a2 --- /dev/null +++ b/zenhttp/iothreadpool.cpp @@ -0,0 +1,36 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#include "iothreadpool.h" + +namespace zen { + +WinIoThreadPool::WinIoThreadPool(int InThreadCount) +{ + // Thread pool setup + + m_ThreadPool = CreateThreadpool(NULL); + + SetThreadpoolThreadMinimum(m_ThreadPool, InThreadCount); + SetThreadpoolThreadMaximum(m_ThreadPool, InThreadCount * 2); + + InitializeThreadpoolEnvironment(&m_CallbackEnvironment); + + m_CleanupGroup = CreateThreadpoolCleanupGroup(); + + SetThreadpoolCallbackPool(&m_CallbackEnvironment, m_ThreadPool); + + SetThreadpoolCallbackCleanupGroup(&m_CallbackEnvironment, m_CleanupGroup, NULL); +} + +WinIoThreadPool::~WinIoThreadPool() +{ + CloseThreadpool(m_ThreadPool); +} + +void +WinIoThreadPool::CreateIocp(HANDLE IoHandle, PTP_WIN32_IO_CALLBACK Callback, void* Context) +{ + m_ThreadPoolIo = CreateThreadpoolIo(IoHandle, Callback, Context, &m_CallbackEnvironment); +} + +} // namespace zen |