1

I want to share a data with multiple processes. My first attempt is to use Point to point message queue with multiple readers since I read that P2P Msg Queue is very fast.

During my test, it seems like multiple readers are reading from the same queue and once a message is fetched by one reader, other readers will not be able to fetch the same message.

What is a better IPC for sharing data to multiple processes? The data is updated frequently (multiple times per second) so I think WM_COPYDATA is not a good choice and will interfere with the "normal" message queue.

My second attempt will probably be a shared memory + mutex + events

4

2 回答 2

2

点对点队列可以正常工作。是的,当您发送时,只有一个接收者会收到消息,但发送者可以查询队列(通过调用GetMsgQueueInfo)以查看有多少侦听器(MSGQUEUEINFO 的 wNumReaders 成员并简单地重复该消息次数。

于 2010-08-25T12:26:24.673 回答
0

最后,对于多个线程或进程打开同一个队列进行读访问或写访问是完全有效的。点对点消息队列支持多读多写。例如,这种做法允许一个写入进程向多个客户端进程发送消息,或者多个写入进程向一个读取进程发送消息。但是,没有办法将消息寻址到特定的读取器进程。当一个进程或线程读取队列时,它将读取下一条可用消息。也无法将消息广播给多个读者。

编程 Windows Embedded CE 6.0 开发人员参考,第四版,Douglas Boiling,第 304 页

尽管有警告,但 ctacke 的 ide 似乎适合我的用例。

警告:
我的队列读者需要Sleep(10)在他们获取他们的消息份额后才能允许其他读者去获取消息。如果没有Sleep(),则只有一个读取器进程收到等待的信号。

于 2010-08-30T03:39:33.060 回答