1 // 2 // timer.cpp 3 // ~~~~~~~~~ 4 // 5 // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 // 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 // 10 11 #include <iostream> 12 #include <boost/asio.hpp> 13 print(const boost::system::error_code &)14void print(const boost::system::error_code& /*e*/) 15 { 16 std::cout << "Hello, world!" << std::endl; 17 } 18 main()19int main() 20 { 21 boost::asio::io_context io; 22 23 boost::asio::steady_timer t(io, boost::asio::chrono::seconds(5)); 24 t.async_wait(&print); 25 26 io.run(); 27 28 return 0; 29 } 30