我要评分
获取效率
正确性
完整性
易理解

HTL_thread_scheduler_param_t

Table 1 Scheduler parameters

Type

Parameter

Description

HTL_thread_scheduler_target_t

type

Scheduler target type.

HTL_thread_scheduler_init_fn

init

Scheduler initialization function.

HTL_thread_scheduler_run_fn

run

Scheduler running function.

HTL_thread_scheduler_free_fn

free

Scheduler release function.

HTL_thread_scheduler_get_migr_pool_fn

get_migr_pool

Returns a migration pool.

Structure Description

  1. HTL_thread_scheduler_target_t type

    Scheduler target type. Currently, only a ULT can be set as the basic worker.

  2. int (*HTL_thread_scheduler_init_fn::init)(HTL_thread_scheduler_t, HTL_thread_scheduler_config_t)

    Scheduler initialization function that initializes the scheduler based on the scheduler configuration. If HTL_SUCCESS is not returned for init(), the scheduler fails to be created. init() is optional and can be set to NULL.

  3. void* (*HTL_thread_scheduler_run_fn::run)(HTL_thread_scheduler_t)

    Scheduler running function. run() is used to run the scheduler plan. Users can design this function as required. The function contains the following attributes:

    • Scheduling cycle:

      run() fetches the worker from the thread pool associated with the scheduler and runs the worker.

      The scheduler can access pools that are not associated with it. However, if HTL assumes that there is no worker in the pool associated with the scheduler, HTL treats the scheduler as idle and yields the scheduler to its parent.

    • Periodical event check:

      run() periodically invokes the HTL_thread_executor_check_event() function. The frequency is user-defined, but some request processing depends on HTL_thread_executor_check_event().

    • Stopping run() as required:

      run() periodically calls HTL_thread_scheduler_stop(). If HTL_TRUE is returned, run() stops immediately. The frequency is user-defined, but some request processing depends on the mechanism of HTL_thread_scheduler_stop().

    The caller of run() is the worker associated with the scheduler. If this scheduler is the primary scheduler, the underlying executor remains unchanged in run(). run() is mandatory, and users must implement this function.

  4. int (*HTL_thread_scheduler_free_fn::get_migr_pool)(HTL_thread_scheduler_t)

    Scheduler release function. free() deinitializes the scheduler. The return value of free() is ignored.

    free() is optional and can be set to NULL.

    free() is called only when the scheduler is being released. It is not called when its associated worker stops.

  5. HTL_thread_pool_t (*HTL_thread_scheduler_get_migr_pool_fn::get_migr_pool)(HTL_thread_scheduler_t)

    Function for obtaining a migration pool. that returns the thread pool associated with the scheduler. This pool is used as the migration pool.

    If get_migr_pool() returns HTL_THREAD_POOL_NULL or a scheduling-irrelevant pool, an undefined result occurs.

    get_migr_pool() is optional and can be set to NULL. If so, HTL selects a proper pool associated with the scheduler.