Rate This Document
Findability
Accuracy
Completeness
Readability

HTL_thread_scheduler_stop

Checks whether to stop a scheduler.

Interface Definition

int HTL_thread_scheduler_stop(HTL_thread_scheduler_t scheduler, bool *is_stop);

Description

HTL_thread_scheduler_stop() checks whether to stop a scheduler.

  • If yes, set is_stop to true. Otherwise, set is_stop to false.
  • If the scheduler is not running, is_stop is an undefined value.

Parameters

Parameter

Type

Description

Input/Output

scheduler

HTL_thread_scheduler_t

Handle to the scheduler.

Input

is_stop

bool *

Whether to stop a scheduler.

Output

Return Value

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

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
static void sched_run(HTL_thread_scheduler_t sched)
{
    uint32_t work_count = 0;
    sched_data_t *p_data;
    int num_pools;
    HTL_thread_pool_t *pools;
    bool is_stop;

    HTL_thread_scheduler_get_pool_count(sched, &num_pools);
    pools = (HTL_thread_pool_t *)malloc(num_pools * sizeof(HTL_thread_pool_t));
    HTL_thread_scheduler_get_pools(sched, num_pools, 0, pools);
    while (1) {
        ... ...
        if (!(++work_count & sched_event_freq_mask)) {
            HTL_thread_scheduler_stop(sched, &is_stop);
            if (is_stop == true)
                break;
            HTL_thread_executor_check_event(sched);
        }
    }
    free(pools);
}