---
title: aclrtRegStreamStateCallback
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/runtimeapi/aclcppdevg_03_1996.html
sourcePath: /source/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_1996.html
indexId: 0f1db8e4d57d900d85d477916d3cfbcff6d78dc7c9e402483c3a134cae40f0b468
---
# aclrtRegStreamStateCallback

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |


#### 功能说明

注册Stream状态回调函数，不支持重复注册。

当Stream状态发生变化时（例如调用aclrtCreateStream、aclrtDestroyStream等接口），Runtime模块会触发该回调函数的调用。此处的Stream包含显式创建的Stream以及默认Stream。


#### 函数原型

```
aclError aclrtRegStreamStateCallback(const char *regName, aclrtStreamStateCallback callback, void *args)
```


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| regName | 输入 | 注册唯一名称，不能为空，输入保证字符串以\0结尾。 |
| callback | 输入 | 回调函数。若callback不为NULL，则表示注册回调函数；若为NULL，则表示取消注册回调函数。 回调函数的函数原型为： typedef enum { ACL\_RT\_STREAM\_STATE\_CREATE\_POST = 1, // 调用create接口（例如aclrtCreateStream）之后 ACL\_RT\_STREAM\_STATE\_DESTROY\_PRE, // 调用destroy接口（例如aclrtDestroyStream）之前 } aclrtStreamState; typedef void (\*aclrtStreamStateCallback)(aclrtStream stm, aclrtStreamState state, void \*args); |
| args | 输入 | 待传递给回调函数的用户数据的指针。 |


#### 返回值说明

返回0表示成功，返回其他值表示失败，请参见aclError。
