boost::asio学习(定时器)
#include <boost/asio.hpp>
#include <iostream> void handle1(const boost::system::error_code& ec)
{
std::cout << "5.s" << std::endl;
} void handle2(const boost::system::error_code& ec)
{
std::cout << "10.s" << std::endl;
} int main()
{
boost::asio::io_service io_service;//io服务
boost::asio::deadline_timer timer1(io_service, boost::posix_time::seconds());//定时器timer1
timer1.async_wait(handle1);//异步等待
boost::asio::deadline_timer timer2(io_service, boost::posix_time::seconds());//定时器timer2
timer2.async_wait(handle2);//异步等待
io_service.run();//阻塞调用,这个是必须的,这样才能将控制权交给操作系统,可以再一个线程里面阻塞,这个和libevent派发线程很像
}
boost::asio学习(定时器)的更多相关文章
- boost asio 学习(一)io_service的基础
原文 http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting- started-with-boostasio/ 编译环境 b ...
- boost asio 学习(六) 定时器
http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting- started-with-boostasio?pg=7 6 定时器 ...
- boost::asio 学习
安装 下载-解压 指定安装目录 ./bootstrap.sh --prefix=/usr/local/boost_1_68_0 查看所有必须要编译才能使用的库 ./b2 --show-librarie ...
- boost asio 学习(九) boost::asio 网络封装
http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting- started-with-boostasio?pg=10 9. A ...
- boost asio 学习(八) 网络基础 二进制写发送和接收
http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting- started-with-boostasio?pg=9 8. Net ...
- boost asio 学习(七) 网络基础 连接器和接收器(TCP示例)
http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting- started-with-boostasio?pg=8 7. Net ...
- BOOST ASIO 学习专贴
本文已于20170903更新完毕,所有boost asio 代码均为本人手抄.编译器为vs2013,并且所有代码已经上传,本文下方可下载源码 为了学习boost asio库,我是从boost的官方bo ...
- boost::asio::io_service::定时器任务队列
使用io_service和定时器写的一个同步和异步方式的任务队列 #pragma once #include <string> #include <iostream> #inc ...
- boost asio 学习(五) 错误处理
http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting-started-with-boostasio?pg=6 5. Erro ...
随机推荐
- linux 输出重定向 何时会写文件
linux 输出重定向 何时会写文件 测试到了8K才会进行flush:
- 在线安装eclipse中html/jsp/xml editor插件 eclipseeditor
1.打开eclipse中的help————>Install New Software 2.点击Add按钮,然后弹出一个框,第一个文本框可以随便写,第二个一定要写: http://download ...
- Android API Guides---Host-based Card Emulation
Host-based Card Emulation 很多提供NFC功能的Android手机已经支持NFC卡模拟.在大多数情况下.该卡是由在该装置的单独芯片仿真,称为安全元件. 无线运营商提供了非常 ...
- Eclipse重新导入Tomcat启动出错选择不了文件夹
如果你已经把tomcat配置进了Eclipse,却因为某些原因delete了服务器,再想导入同版本的服务器就有可能会报Could not publish to the server.错误,并且添加服务 ...
- Node.js nvshens图片批量下载爬虫 1.00
//====================================================== // www.nvshens.com图片批量下载Node.js爬虫1.00 // 此程 ...
- 【IE兼容性】background:transparent IE中Bug,不能选中input输入框,出现这个问题主要是IE8
先解释下,background:transparent,默认在IE上会被解析成 background: none transparent scroll repeat 0% 0% transparent ...
- Linux学习笔记 (五)关机和重启命令
一.关机命令 1.shutdown命令: shutdown [选项] [时间] 选项: -c:取消前一个关机命令 -h:关机 -r:重启 例:shutdown -r 05:30 & //表 ...
- Web service--百度百科
Web service是一个平台独立的,低耦合的,自包含的.基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述.发布.发现.协调和配置这些应用程序,用于开发分布 ...
- 访问vector元素方法的效率比较(转)
LInux下: gcc 4.47,red hat6 #include<iostream> #include<vector> #include<time.h> usi ...
- sql server 循环
declare @i int declare @a int declare @b int set @i=0 while(@i<=20) begin set @a=@i*1000+1; set @ ...