---
title: HTL_thread_scheduler_stop
description: "检查调度器是否需要停止。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengaccel/system-lib/htl/kunpengaccel_ksl_16_0076.html
sourcePath: /source/zh/kunpengaccel/system-lib/htl/kunpengaccel_ksl_16_0076.html
indexId: dd3d25962ae6d3377b39259081a28224a5ad0065237608659231af876a54fb3668
---
# HTL_thread_scheduler_stop

检查调度器是否需要停止。

#### 接口定义

int HTL_thread_scheduler_stop(HTL_thread_scheduler_t scheduler, bool *is_stop);


#### 描述

HTL_thread_scheduler_stop()用于检查调度器scheduler是否需要停止。

- 如果需要停止scheduler，则将is_stop设置为true。否则，is_stop设置为false。
- 如果sched未运行，则is_stop为未定义的值。


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| scheduler | HTL\_thread\_scheduler\_t | 调度器句柄。 | 输入 |
| is\_stop | bool \* | 调度器是否需要停止。 | 输出 |


#### 返回值

- HTL_THREAD_SUCCESS：成功。
- 其他：失败。见错误码定义。


#### 示例

```
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);
}
```
