---
title: aclrtStreamWaitEvent
description: 阻塞指定Stream的运行，直到指定的Event完成，支持多个Stream等待同一个Event的场景。异步接口。
url: "https://www.hiascend.com/document/detail/zh/Atlas200IDKA2DeveloperKit/23.0.RC2/Application%20Development%20Guide/aadgc/aclcppdevg_03_0076.html"
---

# aclrtStreamWaitEvent

#### 函数功能

阻塞指定Stream的运行，直到指定的Event完成，支持多个Stream等待同一个Event的场景。异步接口。


#### 约束说明

-   aclrtRecordEvent
接口与  aclrtStreamWaitEvent
接口配合使用时，主要用于多Stream之间同步的场景，在调用aclrtRecordEvent接口时，系统内部会申请Event资源，在调用  aclrtStreamWaitEvent
接口之后，请及时调用  aclrtResetEvent
接口释放Event资源。
  接口调用顺序：aclrtCreateEvent-->aclrtRecordEvent-->aclrtStreamWaitEvent-->aclrtResetEvent

- 一个进程内，调用  aclInit
接口初始化AscendCL后，调用  aclrtSetOpWaitTimeout
接口设置超时时间，本进程内后续调用  aclrtStreamWaitEvent
接口下发的任务支持在所设置的超时时间内等待，若等待的时间超过所设置的超时时间，则AscendCL会返回报错。
  由于aclrtStreamWaitEvent接口是异步接口，调用接口成功仅表示任务下发成功，不表示任务执行成功，因此若等待的时间超过所设置的超时时间，则在调用aclrtSynchronizeStream接口后，会返回报错。


#### 函数原型

aclError aclrtStreamWaitEvent(aclrtStream stream, aclrtEvent event)


#### 参数说明

| 参数名 | 输入/输出 | 说明 |
| --- | --- | --- |
| stream | 输入 | 指定需要等待Event完成的Stream。 如果使用默认Stream，此处设置为NULL。 |
| event | 输入 | 需等待的Event。 |


#### 返回值说明

返回0表示成功，返回其它值表示失败。


#### 参考资源

- 接口调用流程，参见  多Stream时的同步等待流程
。
- 接口调用示例，参见  Event的同步等待示例代码
、  Stream间任务的同步等待示例代码
。
