gpt4 book ai didi

linux - 使用 message_queue 进行双向消息传递时 boost.interprocess 的问题

转载 作者:太空宇宙 更新时间:2023-11-04 11:56:39 24 4
gpt4 key购买 nike

我正在尝试使用 boost.interprocess 和 message_queue 在两个进程之间实现消息传递系统。

第一个问题:一个队列只能用于进程A向B发送消息,不能用于B向A发送消息。

因此,我在两个进程中都使用了两个队列。进程 A 在 Queue-A 上监听/接收并在 Queue-B 上发送;进程 B 在队列 B 上监听/接收并在队列 A 上发送。

我无法让 to 系统同时处理两个队列。根据进程调用 boost::interprocess::message_queue(boost::interprocess::open_or_create,...) 的顺序或

boost::interprocess::message_queue(boost::interprocess::open_only,...)

要么一个队列工作,要么另一个工作,要么都不工作。

即使进程 A 创建了 Queue-A 和 Queue-B,而进程 B 打开了 Queue-A 和 Queue-B,也只是这样。在一个方向上,boost::interprocess 卡在接收函数中,永远不会醒来。

1) 是否有可能在每个进程中使用两个队列来获得双向消息/信号以与 interprocess::message_queue 一起工作?2) 有没有更好的方法在不使用 message_queue 的情况下获得双向消息传递?

最佳答案

我没有收到任何对此的评论。解决方案是不使用 boost::interprocess::message_queue。在 boost/interprocess/shared_memory_object 的帮助下,我确实自己编写了一个新的、简单的单向进程间消息传递库。 https://github.com/svebert/InterprocessMsg

关于linux - 使用 message_queue 进行双向消息传递时 boost.interprocess 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54099281/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com