Rate This Document
Findability
Accuracy
Completeness
Readability

HTL_thread_pool_create

Creates a thread pool.

Interface Definition

int HTL_thread_pool_create(HTL_thread_pool_t *thread_pool, HTL_thread_pool_type_t pool_type, HTL_thread_pool_access_mode_t access_mode, bool is_auto);

Description

HTL_thread_pool_create() creates a thread pool and returns the handle through thread_pool. The pool type pool_type, access mode access_mode, and automatic release flag is_auto need to be specified.

pool_type specifies the implementation mode of the thread pool. For details, see the enumeration of HTL_thread_pool_type_t.

access_mode specifies the mode of using the thread pool. HTL has an optimized pool selection implementation with stricter access control, that is, HTL_THREAD_POOL_ACCESS_MODE_PRIV. For details, see the enumeration of HTL_thread_pool_access_mode_t.

  • If is_auto is false, thread_pool is not automatically released. It must be released by HTL_thread_pool_free() after being used unless thread_pool is associated with the primary scheduler of the primary executor.
  • If is_auto is true, thread_pool is automatically released when all schedulers associated with thread_pool are released. If the new pool is not associated with the scheduler, users need to manually release thread_pool.

Parameters

Parameter

Type

Description

Input/Output

thread_pool

HTL_thread_pool_t *

Address of the handle to the created thread pool.

Output

pool_type

HTL_thread_pool_type_t

Thread pool type.

Input

access_mode

HTL_thread_pool_access_mode_t

Thread pool access mode.

Input

is_auto

bool

Automatic pool release flag.

Input

Return Value

  • HTL_THREAD_SUCCESS: success.
  • Other values: failure. For details, see the error code descriptions.

Example

    HTL_thread_pool_t *pools = (HTL_thread_pool_t *)malloc(sizeof(HTL_thread_pool_t) * num_executors);
    for (i = 0; i < num_executors; i++) {
        HTL_thread_pool_create(HTL_THREAD_POOL_FIFO, HTL_THREAD_POOL_ACCESS_MODE_MIMO, true,
                               &g_pools[i]);
    }