This tutorial demonstrates the use of the boost::asio::strand class to synchronise callback handlers in a multithreaded program.The previous four tuto...
分类:
其他好文 时间:
2015-04-28 01:38:34
阅读次数:
168
#include#includeintmain(){boost::asio::io_serviceio;boost::asio::deadline_timertimer(io,boost::posix_time::seconds(3));timer.wait();std::coutexpires_a...
分类:
其他好文 时间:
2015-04-27 23:33:37
阅读次数:
153
同步Timerasio中提供的timer名为deadline_timer,它提供了超时计时的功能。首先以一个最简单的同步Timer为例来演示如何使用它。#include#includeintmain(){boost::asio::io_serviceio;boost::asio::deadline_...
分类:
其他好文 时间:
2015-04-27 23:27:47
阅读次数:
230
//C++智能指针模板类复习
#include
#include
using namespace std;
//智能指针用于确保程序不存在内存和资源泄漏且是异常安全的。
//C++98中提供了auto_ptr,C++11摒弃了auto_ptr,并提出了unique_ptr 、shared_ptr、weak_ptr
void show1()
{
int* p = ne...
分类:
编程语言 时间:
2015-04-27 21:57:40
阅读次数:
247
1. 官网下载最新的Boost库,我的是1.552.在使用vs2013编译boost-1.55.0之前,先要给boost做下修改:boost_1_55_0\boost\intrusive\detail\has_member_function_callable_with.hpp line:222tem...
分类:
其他好文 时间:
2015-04-27 21:30:24
阅读次数:
171
//#45 运用成员函数模版接受所有兼容类型
{
/* 1:当你使用智能指针的时候,会发生一个问题,想把一个子类的对象赋给基类的指针变得不可能了,
因为智能指针指定了的是基类的类型,而赋给它的是一个它的子类的对象。
2:解决办法,使用成员函数模版,可以分别对拷贝构造函数和赋值操作进行模版化: */
templatecla...
分类:
编程语言 时间:
2015-04-26 10:55:34
阅读次数:
208
一哥们翻译的boost的无锁队列的官方文档原文地址:http://blog.csdn.net/great3779/article/details/8765103Boost_1_53_0终于迎来了久违的Boost.Lockfree模块,本着学习的心态,将其翻译如下。(原文地址:http://www.b...
分类:
其他好文 时间:
2015-04-25 16:36:13
阅读次数:
142
最近在学习Boost的智能指针,下面对一些很好的文章进行整理如下:Boost智能指针——scoped_ptrhttp://www.cnblogs.com/TianFang/archive/2008/09/15/1291050.htmlBoost智能指针——shared_ptrhttp://www.c...
分类:
其他好文 时间:
2015-04-25 13:23:54
阅读次数:
125
转自:http://blog.csdn.net/zhuky/archive/2010/03/10/5364574.aspxBoost.Asio是一个跨平台的网络及底层IO的C++编程库,它使用现代C++手法实现了统一的异步调用模型。头文件#include 名空间using namespace boo...
分类:
其他好文 时间:
2015-04-25 12:00:34
阅读次数:
103
利用boost来获取当前时间又方便快捷,还不用考虑跨平台的问题。1. 输出YYYYMMDD[cpp]view plaincopy#include#defineBOOST_DATE_TIME_SOURCEstd::stringstrTime=boost::gregorian::to_iso_strin...
分类:
其他好文 时间:
2015-04-25 10:32:13
阅读次数:
165