轻量级自描述缓冲区

来源:互联网 发布:淘宝网代购服务店加盟 编辑:程序博客网 时间:2024/05/22 10:47

对上篇博文中提到的缓冲区模板类型做一些补充说明。

下面这段是笔者的源码注释,是对上篇博文有关该缓冲区模板的重要补充说明。

烽驿2009开源实时通信平台 源码位置:svn checkout http://fy2009.googlecode.com/svn/trunk/ fy2009-read-only

/*[tip] buffer type template
 *[desc]
 * buffer is very often used in communication software, plain c char* isn't good enough to used as out parameter
 * (without length info and indicator to tell where the buffer is allocated(stack or heap). std::string or
 * std::vector<char> can meet above need, unfortunatedly, they often has an expensive constructor.
 * for performance of basic service, below buffer type is perferred to be used in basic service.
 * if buffer is allocated on heap, its lifecycle will be controlled by this class
 *
 *[memo]
 * spending of a million constructions:
 *            std::vector<char>: 80ms; std::string: 150ms; this type: 20ms--it's excellent,2008-4-7
 *[history]
 * initialize: 2006-7-28
 * revise 2008-4-7
 */

原创粉丝点击