Use helper function for async_wait

PosixStream waits 100ms before reconnecting
This commit is contained in:
badaix 2020-01-05 14:36:46 +01:00
parent 5c79d9447d
commit 9353c61d7b
5 changed files with 36 additions and 68 deletions

View file

@ -98,11 +98,7 @@ void TcpStream::do_connect()
else
{
LOG(DEBUG) << "Connect failed: " << ec.message() << "\n";
reconnect_timer_.expires_after(std::chrono::milliseconds(1000));
reconnect_timer_.async_wait([self, this](const boost::system::error_code& ec) {
if (!ec)
connect();
});
wait(reconnect_timer_, 1s, [this] { connect(); });
}
});
}
@ -117,4 +113,4 @@ void TcpStream::do_disconnect()
acceptor_->cancel();
reconnect_timer_.cancel();
}
}
} // namespace streamreader