Completed PR #153: using steady timer instead of deadline timer to remove boost dependency when using standalone asio
This commit is contained in:
parent
28803d81be
commit
f7ddeeda82
2 changed files with 6 additions and 4 deletions
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#ifdef USE_STANDALONE_ASIO
|
||||
#include <asio.hpp>
|
||||
#include <asio/steady_timer.hpp>
|
||||
namespace SimpleWeb {
|
||||
using error_code = std::error_code;
|
||||
using errc = std::errc;
|
||||
|
|
@ -18,6 +19,7 @@ namespace SimpleWeb {
|
|||
} // namespace SimpleWeb
|
||||
#else
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/steady_timer.hpp>
|
||||
#include <boost/utility/string_ref.hpp>
|
||||
namespace SimpleWeb {
|
||||
namespace asio = boost::asio;
|
||||
|
|
@ -106,7 +108,7 @@ namespace SimpleWeb {
|
|||
bool in_use = false;
|
||||
bool attempt_reconnect = true;
|
||||
|
||||
std::unique_ptr<asio::deadline_timer> timer;
|
||||
std::unique_ptr<asio::steady_timer> timer;
|
||||
|
||||
void set_timeout(long seconds = 0) noexcept {
|
||||
if(seconds == 0)
|
||||
|
|
@ -115,8 +117,8 @@ namespace SimpleWeb {
|
|||
timer = nullptr;
|
||||
return;
|
||||
}
|
||||
timer = std::unique_ptr<asio::deadline_timer>(new asio::deadline_timer(socket->get_io_service()));
|
||||
timer->expires_from_now(boost::posix_time::seconds(seconds));
|
||||
timer = std::unique_ptr<asio::steady_timer>(new asio::steady_timer(socket->get_io_service()));
|
||||
timer->expires_from_now(std::chrono::seconds(seconds));
|
||||
auto self = this->shared_from_this();
|
||||
timer->async_wait([self](const error_code &ec) {
|
||||
if(!ec) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue