提升消息队列
我有以下 boost::interprocess::message_queue 相关问题。
按照预期,我计划在 >= 2 个进程之间共享一个消息队列。显然,其中之一可能会在消息队列内崩溃。结果,它将持有内部锁,使其他进程无法访问该队列。如何解决这个问题?似乎没有办法解锁所使用的内部互斥体。
I have the following boost::interprocess::message_queue related question.
As intended I plan to share a message queue between >= 2 processes. Obviously one of them may crash while inside the message queue. As result it will hold the internal locks, making the queue inaccessible for other processes. How can this be solved? There does not seem to be a way to unlock the internal mutex used.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们可以在其他进程中使用谓词等待的方法(根据要求1分钟或更长),如果满足则由第二个进程强制解锁队列,然后再次锁定推送并在读取后解锁?
有关更多详细信息,请参阅下面的参考文献。
http://en.cppreference.com/w/cpp/thread/condition_variable/wait
编辑:
我们无法解锁内部锁,我以为您正在手动锁定队列
使用
因此,您可以在时间结束时使用 predicate_wait 解锁,然后解锁。
来自其他进程。
We can use the method of predicate wait in other processes(1 min or greater based on requirement) then if that satisfies then forcefully unlock the queue by the second process then again lock for pushing and unlock after reading?
for more details see the below ref.
http://en.cppreference.com/w/cpp/thread/condition_variable/wait
Edit:
We can't unlock the internal locks, I thought that you are manually locking the queue
using
So you can unlock using the predicate_wait when the time finished then unlock it.
from other process.