WaitForSingleObject() & 的等效性Linux 中的 ResetEvent() [英] Equivalence of WaitForSingleObject() & ResetEvent() in Linux

查看:36
本文介绍了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天全站免登陆