blob: 9db196916a2437b883fa6829228ed75cd7b8c87b [file] [log] [blame]
Brandon Kim554fad02022-05-15 15:41:05 -07001#include <boost/asio.hpp>
2
3#include <chrono>
4#include <functional>
5
6namespace
7{
8// Set the read loop interval to be 1 second for now
9// TODO: Make this a configuration option
10static constexpr std::chrono::seconds readIntervalSec(1);
11} // namespace
12
13// boost::async_wait requires `const boost::system::error_code&` parameter
14void readLoop(boost::asio::steady_timer* t, const boost::system::error_code&)
15{
16 /* This will run every readIntervalSec second for now */
17 t->expires_from_now(readIntervalSec);
18 t->async_wait(std::bind_front(readLoop, t));
19}
20
21int main()
22{
23 boost::asio::io_context io;
24 boost::asio::steady_timer t(io, readIntervalSec);
25
26 t.async_wait(std::bind_front(readLoop, &t));
27
28 io.run();
29
30 return 0;
31}