#include #include #include #include #include boost::asio::io_service io_service; boost::asio::steady_timer timer(io_service); void arm_timer() { std::cout << "."; std::cout.flush(); timer.expires_from_now(boost::chrono::seconds(3)); timer.async_wait(boost::bind(&arm_timer)); } int main() { // Add asynchronous work loop. arm_timer(); boost::thread poll_thread( boost::bind(&boost::asio::io_service::poll, boost::ref(io_service))); // Give time for poll thread service reactor. boost::this_thread::sleep_for(boost::chrono::seconds(1)); io_service.run(); }