mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
Merge pull request #11897 from akallabeth/threadpool
[winpr,pool] limit minimum threadpool size
This commit is contained in:
@@ -130,21 +130,25 @@ static BOOL InitializeThreadpool(PTP_POOL pool)
|
||||
#if !defined(WINPR_THREADPOOL_DEFAULT_MIN_COUNT)
|
||||
#error "WINPR_THREADPOOL_DEFAULT_MIN_COUNT must be defined"
|
||||
#endif
|
||||
|
||||
SYSTEM_INFO info = { 0 };
|
||||
GetSystemInfo(&info);
|
||||
if (info.dwNumberOfProcessors < WINPR_THREADPOOL_DEFAULT_MIN_COUNT)
|
||||
info.dwNumberOfProcessors = WINPR_THREADPOOL_DEFAULT_MIN_COUNT;
|
||||
|
||||
if (!SetThreadpoolThreadMinimum(pool, info.dwNumberOfProcessors))
|
||||
goto fail;
|
||||
|
||||
#if !defined(WINPR_THREADPOOL_DEFAULT_MAX_COUNT)
|
||||
#error "WINPR_THREADPOOL_DEFAULT_MAX_COUNT must be defined"
|
||||
#endif
|
||||
|
||||
SYSTEM_INFO info = { 0 };
|
||||
GetSystemInfo(&info);
|
||||
|
||||
DWORD min = info.dwNumberOfProcessors;
|
||||
DWORD max = info.dwNumberOfProcessors;
|
||||
if (max > WINPR_THREADPOOL_DEFAULT_MAX_COUNT)
|
||||
if (info.dwNumberOfProcessors < WINPR_THREADPOOL_DEFAULT_MIN_COUNT)
|
||||
min = WINPR_THREADPOOL_DEFAULT_MIN_COUNT;
|
||||
if (info.dwNumberOfProcessors > WINPR_THREADPOOL_DEFAULT_MAX_COUNT)
|
||||
max = WINPR_THREADPOOL_DEFAULT_MAX_COUNT;
|
||||
if (min > max)
|
||||
min = max;
|
||||
|
||||
if (!SetThreadpoolThreadMinimum(pool, min))
|
||||
goto fail;
|
||||
|
||||
SetThreadpoolThreadMaximum(pool, max);
|
||||
|
||||
rc = TRUE;
|
||||
|
||||
Reference in New Issue
Block a user