Skip to content

Instantly share code, notes, and snippets.

@rahul8590
Created June 18, 2013 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahul8590/5805934 to your computer and use it in GitHub Desktop.
Save rahul8590/5805934 to your computer and use it in GitHub Desktop.
Just goofing around Boost ASIO library . The following is the first attempt to mess with it.
// You also need to link pthread and boost_system in order to run it. The following will be the command , if you are too lazy to
// type
// $ g++ sample_asio.cpp -o asio -lpthread -lboost_system
//
#include <boost/asio.hpp>
#include <iostream>
using namespace std;
void handler(const boost::system::error_code &ec)
{
cout << "printing after 5 sec";
}
int main()
{
boost::asio::io_service io_service;
boost::asio::deadline_timer timer(io_service, boost::posix_time::seconds(5));
timer.async_wait(handler);
io_service.run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment