mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[winpr,pool] limit threadpool to 16 threads by default
Initialize the threadpool to minimum of number of processors and 16 by default.
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set(WINPR_THREADPOOL_DEFAULT_MAX_COUNT "16" CACHE STRING "The maximum (default) number of threads in a pool")
|
||||
winpr_definition_add(WINPR_THREADPOOL_DEFAULT_MAX_COUNT=${WINPR_THREADPOOL_DEFAULT_MAX_COUNT})
|
||||
winpr_module_add(
|
||||
synch.c
|
||||
work.c
|
||||
|
||||
@@ -133,7 +133,14 @@ static BOOL InitializeThreadpool(PTP_POOL pool)
|
||||
info.dwNumberOfProcessors = 1;
|
||||
if (!SetThreadpoolThreadMinimum(pool, info.dwNumberOfProcessors))
|
||||
goto fail;
|
||||
SetThreadpoolThreadMaximum(pool, info.dwNumberOfProcessors);
|
||||
|
||||
#if !defined(WINPR_THREADPOOL_DEFAULT_MAX_COUNT)
|
||||
#error "WINPR_THREADPOOL_DEFAULT_MAX_COUNT must be defined"
|
||||
#endif
|
||||
DWORD max = info.dwNumberOfProcessors;
|
||||
if (max > WINPR_THREADPOOL_DEFAULT_MAX_COUNT)
|
||||
max = WINPR_THREADPOOL_DEFAULT_MAX_COUNT;
|
||||
SetThreadpoolThreadMaximum(pool, max);
|
||||
|
||||
rc = TRUE;
|
||||
|
||||
@@ -143,9 +150,7 @@ fail:
|
||||
|
||||
PTP_POOL GetDefaultThreadpool(void)
|
||||
{
|
||||
PTP_POOL pool = NULL;
|
||||
|
||||
pool = &DEFAULT_POOL;
|
||||
PTP_POOL pool = &DEFAULT_POOL;
|
||||
|
||||
if (!InitializeThreadpool(pool))
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user