C++进程间通信的最佳方式

Best way for interprocess communication in C++(C++进程间通信的最佳方式)
本文介绍了C++进程间通信的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我有两个进程,一个会查询另一个数据.在有限的时间内(每秒 10000 次)会有大量查询,并且每秒将传输数据(>100 mb).数据类型将是一个整体类型(双,整数)我的问题是用什么方式连接这个过程?

I have two processes one will query other for data.There will be huge amount of queries in a limited time (10000 per second) and data (>100 mb) will be transferred per second.Type of data will be an integral type(double,int) My question is in which way to connect this process?

共享内存、消息队列、lpc(本地过程调用)或其他....

Shared memory , message queue , lpc(Local Procedure call) or others....

我还想问你推荐哪个图书馆?顺便说一下,请不要建议 MPI.在 windows xp 32 位下

And also i want to ask which library you suggest? by the way please do not suggest MPI. edit : under windows xp 32 bit

推荐答案

One Word: Boost.InterProcess.如果真的需要快速,共享内存是最佳选择.由于操作系统在虚拟地址和物理地址之间进行通常的映射,并且不需要数据副本,因此您的开销几乎为零.您只需要注意并发问题.

One Word: Boost.InterProcess. If it really needs to be fast, shared memory is the way to go. You nearly have zero overhead as the operation system does the usual mapping between virtual and physical addresses and no copy is required for the data. You just have to lookout for concurrency issues.

对于像 shutdownquery 这样的实际发送命令,我会使用消息队列.在我了解 boost 之前,我以前使用 localhost 网络编程来做到这一点,并使用手动共享内存分配.该死的,如果我需要重写应用程序,我会立即选择 boost.Boost.InterProcess 使这对您来说更容易.看看吧.

For actually sending commands like shutdown and query, I would use message queues. I previously used localhost network programming to do that, and used manual shared memory allocation, before i knew about boost. Damn if i would need to rewrite the app, I would immediately pick boost. Boost.InterProcess makes this more easy for you. Check it out.

这篇关于C++进程间通信的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

OpenGL transforming objects with multiple rotations of Different axis(OpenGL 变换不同轴多次旋转的对象)
GLFW first responder error(GLFW 第一响应者错误)
SOIL not linking correctly(SOIL 连接不正确)
Core profile vs version string? Only getting GLSL 1.3/OGL 3.0 in mesa 10.0.1(核心配置文件与版本字符串?在 mesa 10.0.1 中只获得 GLSL 1.3/OGL 3.0)
What is the range of OpenGL texture ID?(OpenGL 纹理 ID 的范围是多少?)
How taxing are OpenGL glDrawElements() calls compared to basic logic code?(与基本逻辑代码相比,OpenGL glDrawElements() 调用的繁重程度如何?)