首页 | 本学科首页   官方微博 | 高级检索  
     

一种轻量级的对象通信机制设计与实现
引用本文:曾颖超,王茂芝,冯伟桓. 一种轻量级的对象通信机制设计与实现[J]. 计算机工程与科学, 2016, 38(3): 437-442
作者姓名:曾颖超  王茂芝  冯伟桓
作者单位:;1.成都理工大学数学地质四川省重点实验室
摘    要:针对对象间跨线程或跨DLL通信时容易增加对象之间耦合度的现象,借鉴Action Script 3.0语言中事件模型以及PC机总线通信的思想,提出一种基于C++11的轻量级对象间通信机制。在设计上,该机制采用事件作为通信载体,事件可以在总线上传输形成事件流,同时也能被设置了相应类型监听器的对象捕捉。对象(或DLL)实质上是在和总线进行交互,交互接口是用户预定义好的一些事件,从而有效降低对象之间的耦合度。在实现上,该机制定义了一个两层的体系结构——运输层和适配层。让适配层(顶层)的各个DLL模块都以隐式链接方式加载运输层提供的DLL,该DLL主要任务是导出一个包含一个静态对象队列、一个静态事件队列和一条总线的类,这样适配层中实例化了此导出类的对象就可以通过接口成员函数方便、安全地访问到运输层的总线,从而完成对象间的交互。本文中使用的方法对编写大型软件系统的基础通信架构具有参考价值。

关 键 词:通信机制  跨DLL通信  软总线  跨线程通信  低耦合
收稿时间:2015-04-07
修稿时间:2016-03-25

Design and implementation of a lightweight object communication mechanism
ZENG Ying chao,WANG Mao zhi,FENG Wei huan. Design and implementation of a lightweight object communication mechanism[J]. Computer Engineering & Science, 2016, 38(3): 437-442
Authors:ZENG Ying chao  WANG Mao zhi  FENG Wei huan
Affiliation:(Geomathematics Key Laboratory of Sichuan Province,Chengdu University of Technology,Chengdu 610059,China)
Abstract:When objects communicate with others across different DLLs or threads, the system coupling degree can be easily increased. In order to solve this problem, using the idea of Event model in Action Script 3.0 and the computer bus communication for reference, we design a lightweight object communication mechanism based on C++11. This lightweight object communication mechanism uses events as the message carrier, which can not only be transmitted and forms an event stream on the bus, but also can be caught by the objects with corresponding listener types. Objects or DLLs essentially interact with the bus, and the interface between the two is predefined events, thus the coupling between objects can be effectively reduced. This mechanism builds a two layer architecture: the transport layer and the adaptation layer. The DLL belonging to the transport layer will load the DLL provided by the adaptation layer through implicit linking. The DLL provided by the adaptation layer contains a static object queue, a static event queue and a bus, thus all the individual objects in the adaptation layer can easily and safely complete the interaction between objects by calling its own member functions.
Keywords:communication mechanism  cross DLL communication  software bus  cross thread communication  loose coupling,
点击此处可从《计算机工程与科学》浏览原始摘要信息
点击此处可从《计算机工程与科学》下载全文
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号