Admin Production ni-theme
Current Publication

CmtPreAllocThreadPoolThreads

LabWindows/CVI

CmtPreAllocThreadPoolThreads

int CmtPreAllocThreadPoolThreads (CmtThreadPoolHandle poolHandle, int numberOfThreads, int *numberOfThreadsCreated);

Purpose

Call this function only if you want to make sure that a certain number of threads exist or are available to execute scheduled functions. Call CmtGetThreadPoolAttribute with the ATTR_TP_NUM_THREADS attribute to determine the number of threads already in the pool.

CmtPreAllocThreadPoolThreads attempts to create a specified number of threads in the pool. If adding the specified number of threads yields more threads than the maximum allowed for the pool, only enough threads are created to reach the maximum. You can use this function to control the time at which your program incurs the overhead of creating threads.

The maximum number of threads in a pool is set when it is created. Call CmtSetThreadPoolAttribute with the ATTR_TP_MAX_NUM_THREADS attribute to change the maximum.

Parameters

Input
Name Type Description
poolHandle CmtThreadPoolHandle The handle you obtained from CmtNewThreadPool to identify the thread pool.

Do not pass DEFAULT_THREAD_POOL_HANDLE to this function.
numberOfThreads int The additional number of threads to create in the thread pool.

Call CmtGetThreadPoolAttribute with the ATTR_TP_NUM_THREADS attribute to determine how many threads have already been created in the thread pool.
Output
Name Type Description
numberOfThreadsCreated int The actual number of threads added to the pool.

Pass NULL if you do not want this value.

Return Value

Name Type Description
cmtStatus int The CmtStatus code that the function call returns. This function returns 0 to indicate success and negative values to indicate failure. Pass the CmtStatus code to CmtGetErrorMessage to get a description of the error code.

Additional Information

Library: Utility Library

Include file: utility.h

LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later