HcommThreadNotifyWaitOnThread
产品支持情况
产品 |
是否支持 |
|---|---|
√ |
|
√ |
|
☓ |
|
☓ |
|
☓ |
针对
功能说明
等待同步信号,该接口会阻塞等待Thread的运行,直到指定的Notify被record完成。
函数原型
1 | int32_t HcommThreadNotifyWaitOnThread(ThreadHandle thread, uint32_t notifyIdx, uint32_t timeout) |
参数说明
参数名 |
输入/输出 |
描述 |
|---|---|---|
thread |
输入 |
线程句柄,为通过HcclThreadAcquire接口获取到的threads。 ThreadHandle类型的定义请参见ThreadHandle。 |
notifyIdx |
输入 |
需等待的Notify通知索引。 取值范围为:[0, HcclThreadAcquire接口传入的notifyNumPerThread参数的值)。 |
timeout |
输入 |
超时时间,单位:毫秒。
|
返回值
int32_t:接口成功返回0,其他失败。
约束说明
该接口需要配合HcommThreadNotifyRecordOnThread使用。
调用示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | HcclComm comm; CommEngine engine = COMM_ENGINE_CPU_TS; aclrtStream streams[2]; ThreadHandle threads[2]; // 申请2条流,每条流2个Notify aclrtCreateStream(&streams[0]); aclrtCreateStream(&streams[1]); HcclResult result = HcclThreadAcquireWithStream(comm, engine, streams[0], 2, &threads[0]); result = HcclThreadAcquireWithStream(comm, engine, streams[1], 2, &threads[1]); uint32_t notifyIdx = 0; // 发送同步信号 HcommThreadNotifyRecordOnThread(threads[0], threads[1], notifyIdx); uint32_t timeout = 1; // 等待同步信号 HcommThreadNotifyWaitOnThread(threads[1], notifyIdx, timeout); |
父主题: 本地操作