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 ...
随机推荐
- Bat 获取本地代码的Svn Revision并保存到变量
echo off & color 0A for /f "usebackq delims=" %%i in (`"svn info Server | findstr ...
- try....exception....finally
class MyException(Exception): def __init__(self,msg): self.msg=msg def __str__(self): return self.ms ...
- ArcGIS Engine读取GDB中的Shape
string gdbPath = @"D:\Documents\ArcGIS\Default.gdb"; FileGDBWorkspaceFactoryClass pFileGDB ...
- 让C#可以像Javascript一样操作Json DynamicJson
http://blog.csdn.net/lisenyang/article/details/52535314
- C++中的INL(转)
inl 文件是内联函数的源文件. 内联函数通常在c++头文件中实现,但有的时候内联函数较多或者出于一些别的考虑(使头文件看起来更简洁等), 往往会将这部分具体定义的代码添加到INL文件中,然后在该头文 ...
- Wp8滚动区域(ScrollViewer)控件的使用
1. <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28" ...
- spring事务管理源码解析--加了@Transactional注解后Spring究竟为我们做了哪些事情?
大家都知道事务管理是基于AOP的,对AOP还不了解的请自行百度. 实现一个事务需要以下几步:1.获取数据库连接 2.执行数据库操作 3.如果2步骤发生异常就回滚,否则就提交 4.释放资源. 然后 ...
- Linux禁止非WHEEL用户使用SU命令
通常情况下,一般用户通过运行"su -"命令.输入正确的rootpassword.能够登录为root用户来对系统进行管理员级别的配置. 可是.为了更进一步加强系统的安全性,有必要建 ...
- FPGA开发要懂得使用硬件分析仪调试——ILA
0. ILA概述在FPGA开发中,当我们写完代码,进行仿真,确定设计没有问题后,下载到硬件上一般都能按照我们的设计意愿执行相应功能.但这也并非绝对的,有时候你会遇到一些突然情况,比如时序问题或者仿真时 ...
- poj2184 Cow Exhibition(p-01背包的灵活运用)
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:id=2184">http://poj.org/problem?id=2184 Descrip ...