2019-07-01 20:30:21 +02:00
|
|
|
//
|
|
|
|
|
// timer.cpp
|
|
|
|
|
// ~~~~~~~~~
|
|
|
|
|
//
|
|
|
|
|
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
|
|
|
|
//
|
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include <boost/asio.hpp>
|
2024-02-02 12:25:34 -06:00
|
|
|
#include <boost/container/devector.hpp>
|
2019-07-01 20:30:21 +02:00
|
|
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
2021-01-06 14:40:33 +01:00
|
|
|
#include <iostream>
|
2024-02-02 12:25:34 -06:00
|
|
|
#include <string>
|
2019-07-01 20:30:21 +02:00
|
|
|
|
2024-02-02 12:25:34 -06:00
|
|
|
boost::container::devector<std::string> strings;
|
|
|
|
|
|
|
|
|
|
void print(const boost::system::error_code& /*e*/) {
|
|
|
|
|
for (const auto& a : strings) std::cout << a;
|
|
|
|
|
}
|
2019-07-01 20:30:21 +02:00
|
|
|
|
2021-01-06 14:40:33 +01:00
|
|
|
int main() {
|
2019-07-01 20:30:21 +02:00
|
|
|
boost::asio::io_service io;
|
|
|
|
|
|
2024-02-02 12:25:34 -06:00
|
|
|
strings.push_back("Hello, world!\n");
|
|
|
|
|
|
2019-07-01 20:30:21 +02:00
|
|
|
boost::asio::deadline_timer t(io, boost::posix_time::seconds(1));
|
|
|
|
|
t.async_wait(&print);
|
|
|
|
|
|
|
|
|
|
io.run();
|
|
|
|
|
|
|
|
|
|
return 0;
|
2024-02-02 12:25:34 -06:00
|
|
|
}
|