mirror of
https://github.com/boostorg/asio.git
synced 2026-01-21 04:42:11 +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:
@@ -11,17 +11,16 @@
|
||||
#include <iostream>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
void print(const boost::system::error_code& /*e*/,
|
||||
boost::asio::deadline_timer* t, int* count)
|
||||
boost::asio::steady_timer* t, int* count)
|
||||
{
|
||||
if (*count < 5)
|
||||
{
|
||||
std::cout << *count << std::endl;
|
||||
++(*count);
|
||||
|
||||
t->expires_at(t->expires_at() + boost::posix_time::seconds(1));
|
||||
t->expires_at(t->expiry() + boost::asio::chrono::seconds(1));
|
||||
t->async_wait(boost::bind(print,
|
||||
boost::asio::placeholders::error, t, count));
|
||||
}
|
||||
@@ -32,7 +31,7 @@ int main()
|
||||
boost::asio::io_context io;
|
||||
|
||||
int count = 0;
|
||||
boost::asio::deadline_timer t(io, boost::posix_time::seconds(1));
|
||||
boost::asio::steady_timer t(io, boost::asio::chrono::seconds(1));
|
||||
t.async_wait(boost::bind(print,
|
||||
boost::asio::placeholders::error, &t, &count));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user