有没有在Windows中的机制,就像消息队列在Linux呢? [英] Is there was a mechanism in Windows works like message queue in Linux?

查看:79
本文介绍了有没有在Windows中的机制,就像消息队列在Linux呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

近日,笔者找到了一份工作(C / C ++),以在Windows中使用不同的线程之间的消息通信。我用Google搜索,发现在Windows也得到了一个消息队列太多,但它更涉及到一个窗口,其实,我不需要在我的应用程序的任何窗口。

Recently, I got a job(C/C++) to use message communication between different threads in Windows. I Googled and find that the Windows also got a message queue too, but it is more related to a window, actually, I do not need any window in my application.

就像Linux中的消息队列,每个线程创建一个消息队列,并得到了一个消息队列ID,发送消息到该ID,从该ID接收等,这是消息队列我所需要的。

Like the message queue in Linux, each thread create a message queue and got a message queue ID, sending message to that ID, receive from that ID and so on, that is the message queue I need.

有没有类似的机制(S)工作在Windows这样?

Is there any similar mechanism(s) in Windows works like that?

推荐答案

您不需要一个窗口上使用Windows消息,调用的PeekMessage或GetMessage函数得到一个消息队列,你可以用<邮件投递到任何线程A HREF =htt​​p://msdn.microsoft.com/en-us/library/windows/desktop/ms644946%28v=vs.85%29.aspx相对=nofollow> PostThreadMessage 。

You don't need a window to use messages on Windows, any thread that calls PeekMessage or GetMessage gets a message queue and you can post messages to it with PostThreadMessage.

消息应该正常工作在相同的过程,但如果是交叉过程,你需要发送比为size_t以上* 2,你应该看看其他的 IPC机制,共享内存和某种类型的锁定或建立你自己的。 Windows还拥有 MSMQ

Messages should work fine in the same process but if this is cross-process and you need to send more than size_t*2 you should look at other IPC mechanisms or build your own with shared memory and some type of locking. Windows also has MSMQ.

如果您需要确切的POSIX接口与否,无论哪种方式,你没有指定,维基百科有一个列表开源替代品...

You did not specify if you need the exact POSIX interface or not, either way, Wikipedia has a list of open source alternatives...

这篇关于有没有在Windows中的机制,就像消息队列在Linux呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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