2
0
mirror of https://github.com/boostorg/asio.git synced 2026-01-22 05:02:08 +00:00

Update examples to use chrono rather than Boost.Date_Time.

N.B. The Windows-specific tick_count_timer example has been removed as
it has been superseded by timers based on the standard steady_clock.
It's also not clear how to map a wrapping time source to the standard
chrono concepts.
This commit is contained in:
Christopher Kohlhoff
2018-04-01 09:58:45 +10:00
parent 5672713c90
commit 69d54db71f
15 changed files with 111 additions and 244 deletions

View File

@@ -11,13 +11,12 @@
#include <iostream>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
class printer
{
public:
printer(boost::asio::io_context& io)
: timer_(io, boost::posix_time::seconds(1)),
: timer_(io, boost::asio::chrono::seconds(1)),
count_(0)
{
timer_.async_wait(boost::bind(&printer::print, this));
@@ -35,13 +34,13 @@ public:
std::cout << count_ << std::endl;
++count_;
timer_.expires_at(timer_.expires_at() + boost::posix_time::seconds(1));
timer_.expires_at(timer_.expiry() + boost::asio::chrono::seconds(1));
timer_.async_wait(boost::bind(&printer::print, this));
}
}
private:
boost::asio::deadline_timer timer_;
boost::asio::steady_timer timer_;
int count_;
};