0

I am designing a C++ app which consists of largely independent plugins or modules which produce from time to time results useful for other plugins. For example, analysis module comes across some useful piece of data and sends it to action modules. Each module will run in its own thread; this is so analysis modules can continue gathering data while action modules handle the data at the rate they can.

I am looking for a suitable message passing architecture/design pattern. This stackoverflow thread gives some suggestions, but I'm not sure a plain interface will work in multi-threaded environment.

I was thinking of having some sort of channel based architecture, where each module broadcasts something on the channel and whichever module is interested in it - listens to. If there are some ready made libraries under liberal licence - the better.

4

2 回答 2

2

我一直在使用 ACE(自适应通信环境)进行线程管理、TCP/UDP 通信、互斥关系和编程。

ACE 是一个高度可移植的平台核心模式调用集合。最重要的是,它是免费的、开源的,并且目前正在积极开发中。

http://www.cs.wustl.edu/~schmidt/ACE.html

对于您的应用程序,我建议专门查看“ACE_Task_Base”类以提供多线程,以及“ACE_Reactor”类为您的异步回调架构注册所有处理程序。

于 2012-12-22T16:16:31.087 回答
1

您可能有兴趣查看也类似于并发框架的ZeroMQ库。使用这个库,您的组件将通过向命名的 ZeroMQ 套接字发送消息来相互通信。有许多套接字类型(TCP、IPC、inproc)和几种可用于请求-回复和发布-订阅消息传递的模式。

于 2012-12-22T16:03:11.257 回答