博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
boost_tutorial
阅读量:7032 次
发布时间:2019-06-28

本文共 1518 字,大约阅读时间需要 5 分钟。

Microsoft Visual Studio 2010 编译通过

/*  * boost::thread tutorial  *  *  * */  #include 
#include "boost/asio.hpp"#include
#include
using namespace std; #include
//#1 void run() { cout << "Method #1" <
f = boost::bind(&InnerThread2::run, this); boost::thread thread(f); thread.join(); } }; //#4 class SingletonThread { public: void run() { cout << "Singleton thread" <
f = boost::bind(&SingletonThread::run, SingletonThread::getInstance()); boost::thread thread(f); thread.join(); } static SingletonThread* getInstance() { if(!_instance) { _instance = new SingletonThread; } return _instance; } private: SingletonThread() {} static SingletonThread* _instance; }; SingletonThread* SingletonThread::_instance = 0; //#5 class Class { public: void run(const std::string& str) { cout <
<
start(); //#5: Outer class thread Class cls; boost::thread outer_thread(boost::bind(&Class::run, &cls, "Outer thread")); outer_thread.join(); //#6: Complex method: with return value boost::function2
f = &add; boost::packaged_task
pt(boost::bind
(f, 1, 2)); boost::unique_future
fi = pt.get_future(); boost::thread th2(boost::move(pt)); fi.wait(); th2.join(); cout <<"x+y="<
<
pt_cls(boost::bind
(&Class::add, &cls, 1, 2)); boost::unique_future
fi_cls = pt_cls.get_future(); boost::thread th2_cls(boost::move(pt_cls)); fi_cls.wait(); th2_cls.join(); cout <<"x+y="<
<

boost_tutorial

转载于:https://blog.51cto.com/liam2199/2108563

你可能感兴趣的文章
HTTP请求返回状态码详解
查看>>
句柄类
查看>>
GitLab
查看>>
【常用配置】Spring框架web.xml通用配置
查看>>
[leetcode 240]Search a 2D Matrix II
查看>>
域名指的是这一级目录
查看>>
[Angular] Creating an Observable Store with Rx
查看>>
[转]Porting to Oracle with Entity Framework NLog
查看>>
chmod更改文件的权限
查看>>
oracle 10g/11g RAC 启停归档模式
查看>>
poj3461 Oulipo
查看>>
OAuth2.0学习(1-12)开源的OAuth2.0项目和比较
查看>>
Gitlab,这也就O了???
查看>>
2014 百度之星 1003 题解 Xor Sum
查看>>
Linux中在主机上实现对备机上文件夹及文件的操作的C代码实现
查看>>
iOS 块的简单理解
查看>>
idea中如何配置git以及在idea中初始化git
查看>>
关于JQuery Class选择器的一点
查看>>
POJ3264 Balanced Lineup
查看>>
redis-cli 连接远程服务器
查看>>