---
title: HTL_thread_executor_run_worker
description: "执行工作单元。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengaccel/system-lib/htl/kunpengaccel_ksl_16_0061.html
sourcePath: /source/zh/kunpengaccel/system-lib/htl/kunpengaccel_ksl_16_0061.html
indexId: 22c10559ab9eb311a75ef2555c2f342891d2e98f375c6960ddcddd06e061f47568
---
# HTL_thread_executor_run_worker

执行工作单元。

#### 接口定义

int HTL_thread_executor_run_worker(HTL_worker_t worker, HTL_thread_pool_t thread_pool);


#### 描述

HTL_thread_executor_run_worker()将工作单元worker与线程池thread_pool关联，将worker作为子ULT运行在正在调用的ULT上，调用的ULT成为父ULT。当worker完成或退出时，调用的ULT恢复运行。


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| worker | HTL\_worker\_t | 工作单元句柄。 | 输入 |
| thread\_pool | HTL\_thread\_pool\_t | 线程池句柄。 | 输入 |


#### 返回值

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


#### 示例

```
HTL_worker_t unit;
    while (1) {
        /* Execute one work unit from the scheduler's pool */
        HTL_thread_pool_pop(pools[0], &unit);
        if (unit != HTL_THREAD_WORKER_NULL) {
            HTL_thread_executor_run_worker(unit, pools[0]);
        } 
    }
```
