#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学习(定时器)的更多相关文章

  1. boost asio 学习(一)io_service的基础

    原文  http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting- started-with-boostasio/ 编译环境 b ...

  2. boost asio 学习(六) 定时器

    http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting- started-with-boostasio?pg=7 6 定时器 ...

  3. boost::asio 学习

    安装 下载-解压 指定安装目录 ./bootstrap.sh --prefix=/usr/local/boost_1_68_0 查看所有必须要编译才能使用的库 ./b2 --show-librarie ...

  4. boost asio 学习(九) boost::asio 网络封装

    http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting- started-with-boostasio?pg=10 9. A ...

  5. boost asio 学习(八) 网络基础 二进制写发送和接收

    http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting- started-with-boostasio?pg=9 8. Net ...

  6. boost asio 学习(七) 网络基础 连接器和接收器(TCP示例)

    http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting- started-with-boostasio?pg=8 7. Net ...

  7. BOOST ASIO 学习专贴

    本文已于20170903更新完毕,所有boost asio 代码均为本人手抄.编译器为vs2013,并且所有代码已经上传,本文下方可下载源码 为了学习boost asio库,我是从boost的官方bo ...

  8. boost::asio::io_service::定时器任务队列

    使用io_service和定时器写的一个同步和异步方式的任务队列 #pragma once #include <string> #include <iostream> #inc ...

  9. boost asio 学习(五) 错误处理

    http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting-started-with-boostasio?pg=6 5. Erro ...

随机推荐

  1. Codeforces 553B Kyoya and Permutation

    problem 题意 本题题意不太easy看懂. 给定一个序列,我们能够把这个序列变成一些循环置换的和.然而这样的置换的方法是不止一种的.我们定义一种standard cyclic represent ...

  2. Nehe OpenGL lesson 8

    lesson8 Blending: http://nehe.gamedev.net/tutorial/lessons_06__10/17010/ (也许须要特殊手段訪问) There was a re ...

  3. C语言字符串操作总结大全(超具体)

    1)字符串操作 strcpy(p, p1) 复制字符串 strncpy(p, p1, n) 复制指定长度字符串 strcat(p, p1) 附加字符串 strncat(p, p1, n) 附加指定长度 ...

  4. js实现select跳转

    js简单实现select跳转功能:代码例如以下 <!DOCTYPE html> <html> <head> <title></title> ...

  5. 【Excle】Countif函数

    Countif在Excle中是相当的使用,那么我们看下Countif的如下几个功能: ①一对一对比两列数据 ②输入时必须指定包含指定字符 ③帮助Vlookup实现一对多查找 ④统计不重复的个数 一对一 ...

  6. Oracle 数字操作。数字函数。mod(),trunc(),round(),ceil(),floor的使用

    1,取整函数(ceil 向上取整,floor 向下取整) 第一种方式: ) from dual -- 取整 trunc (1.9) = 1 第二种方式 select ceil(66.6) N1,flo ...

  7. python读取文件下的所有文档

    两类文档存储在两个路径下,假设每类文档有25个文档 def spamTest(): docList = [] classList = [] fullText = [] for i in range(1 ...

  8. HTML5之坦克大战游戏开发

    1.在使用arc方法进行画圆时,在IE9+,FF,Safari,Chrome等已经支持HTML5标准的浏览器中进行渲染时,采用逆时针方向画时,也就是说 arc(x, y, radius, startA ...

  9. 关于public class

    初学问题:“The public type movietestdive must be defined in its own file” 对于一个class里,只能出现一个public class(公 ...

  10. 微信错误提示code= -4/微信发送被拒绝

    微信错误提示code= -4/微信发送被拒绝 在做第三方登录时.出现微信授权返回的错误码为:code= -4,原因是由于: (微信开放平台的签名填错了微信平台注冊的签名应该是:使用微信签名工具安卓到手 ...