WaitForSingleObject()的等价物Linux中的ResetEvent() [英] Equivalence of WaitForSingleObject() & ResetEvent() in Linux

查看:164
本文介绍了WaitForSingleObject()的等价物Linux中的ResetEvent()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Linux环境转换一些使用Windows函数编写的代码,但我无法弄清它们在Linux中的等效性.我对WaitForSingleObject的理解是,它等待一个标志,并且在函数结束时,ResetEvent会重置该标志.

I'm trying to translate some code written using windows functions for a Linux environment and I couldn't figure out what the equivalence of these are in Linux. My understanding of WaitForSingleObject is that it waits for a flag and at the end of the function, ResetEvent resets that flag.

我正在使用的代码段编写如下:

The piece of code I'm working with is written as follows:

HANDLE someEvent;
WaitForSingleObject(someEvent, INFINITE);
{ some code }
ResetEvent(someEvent);

推荐答案

您正在寻找pthread_cond_wait

You are looking for pthread_cond_wait

在这里一个简单用法的链接.您将看到交流双方的工作方式.

Here's a link to a simple usage. You will see how both sides of the communication work.

安德烈斯

这篇关于WaitForSingleObject()的等价物Linux中的ResetEvent()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆