boost定时器

#include <iostream>  
#include <boost/asio.hpp> 
#include <boost/bind.hpp>
using namespace std;

void print(const boost::system::error_code& e,
	boost::asio::deadline_timer* t)
{
	cout << "ddd" << endl;
	t->expires_at(t->expires_at() + boost::posix_time::seconds(3));
	t->async_wait(boost::bind(print, boost::asio::placeholders::error, t));
}

void test1()
{
	boost::asio::io_service io;
	boost::asio::deadline_timer t(io, boost::posix_time::seconds(3));
	t.async_wait(boost::bind(print, boost::asio::placeholders::error, &t));
	io.run();
}

int main(void)
{
	test1();
	printf("hehe\n");
	system("pause");
	return 0;
}

你可能感兴趣的:(boost定时器)