23,121
社区成员
发帖
与我相关
我的任务
分享
/* 加锁 */
pthread_cleanup_push(pthread_mutex_unlock, &g_RpcMutex);
pthread_mutex_lock(&g_RpcMutex);
while(g_stRpcRsponseBuf.ulRpcSignalState != OAMS_ADAPT_RPC_SIGNAL_ACTIVED)
{
// 等待rpc消息处理完毕
pthread_cond_wait(&g_RpcCond, &g_RpcMutex);
//printf("thread 1 condition applied\n");
}
......
if(因为某种条件需要退出)
{
/* 退出前需要释放锁,并删除清理函数*/
/* 解锁 */
pthread_mutex_unlock(&g_RpcMutex);
/*问题:在此处加的pop函数会导致编译不过,不加的话清理函数会多余,
这种情况该如何设置清除函数 */
pthread_cleanup_pop(0);
retrun;
}
/* 解锁 */
pthread_mutex_unlock(&g_RpcMutex);
/* 正常的退出点 */
pthread_cleanup_pop(0);
/* 加锁 */
pthread_cleanup_push(pthread_mutex_unlock, &g_RpcMutex);
pthread_mutex_lock(&g_RpcMutex);
while(g_stRpcRsponseBuf.ulRpcSignalState != OAMS_ADAPT_RPC_SIGNAL_ACTIVED)
{
// 等待rpc消息处理完毕
pthread_cond_wait(&g_RpcCond, &g_RpcMutex);
//printf("thread 1 condition applied\n");
}
......
if(因为某种条件需要退出)
{
....
}
/* 解锁 */
pthread_mutex_unlock(&g_RpcMutex);
/* 正常的退出点 */
pthread_cleanup_pop(0);
这样不行吗