---
title: HTL_thread_pool_pop_with_context
description: "从池中按照context方式弹出工作单元。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/251RC1/accel/kunpengaccel_ksl_16_0080.html
sourcePath: /source/zh/kunpengboostkithistory/251RC1/accel/kunpengaccel_ksl_16_0080.html
indexId: 9a083070f73a39a9dc6f2e15dfc243fdffc8a9f60f8cb56803d50623c25f976376
---
# HTL_thread_pool_pop_with_context

从池中按照context方式弹出工作单元。

#### 接口定义

int HTL_thread_pool_pop_with_context(HTL_thread_pool_t thread_pool, HTL_worker_t *worker, uint64_t pool_context);


#### 描述

HTL_thread_pool_pop_with_context()从池thread_pool中按照context方式弹出工作单元，并将其设置为worker。

如果函数成功弹出工作单元，则会将worker设置为获得的HTL_worker_t句柄。否则，此函数将worker设置为HTL_THREAD_WORKER_NULL。context类型由用户自定义。


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| thread\_pool | HTL\_thread\_pool\_t | 线程池句柄。 | 输入 |
| worker | HTL\_worker\_t \* | 工作单元句柄地址。 | 输出 |
| pool\_context | uint64\_t | 操作方式。 | 输入 |


#### 返回值

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


#### 示例

```
int num_pools;
    HTL_thread_pool_t *pools;
    pools = (HTL_thread_pool_t *)malloc(num_pools * sizeof(HTL_thread_pool_t));
    HTL_thread_scheduler_get_pools(sched, num_pools, 0, pools);
    HTL_thread_pool_pop_with_context(pools[0], &unit, 0);
```
