23,124
社区成员
发帖
与我相关
我的任务
分享
while (infoX_Event.flag == 0)
{
dwWaitResult = (__UINT32)pthread_cond_timedwait(&infoX_Event.cv, &infoX_Event.mp, &abst);
if (dwWaitResult == 0) //系统调用返回,需要重新检测flag值
{
// 防止被信号打断,造成错误返回
if (infoX_Event.flag == 0)
{
continue;
}
if (!infoX_Event.bManualReset) //自动RESET
{
infoX_Event.flag = 0;
}
pthread_mutex_unlock(&infoX_Event.mp);
return WAIT_OBJECT_0;
}
else if (dwWaitResult == ETIMEDOUT)
{
pthread_mutex_unlock(&infoX_Event.mp);
return WAIT_TIMEOUT;
}
}