Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated API in Boost.asio #451

Merged
merged 3 commits into from Apr 28, 2020
Merged

Fix deprecated API in Boost.asio #451

merged 3 commits into from Apr 28, 2020

Conversation

tan-wei
Copy link
Contributor

@tan-wei tan-wei commented Apr 21, 2020

get_io_service is marked as deprecated for a long time. Since Boost 1.70, it is removed. So with the latest version Boost, it will cause build fail.
According to the release notes, fix the deprecated API, and confirmed with Boost 1.72.

Copy link
Owner

@chenshuo chenshuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_executor() was introduced in Boost 1.66, released in December 2017.
It will break on Debian 9 stretch and Ubuntu 18.04 LTS as they have older versions of libboost-dev (1.62 and 1.65).

@@ -21,8 +21,8 @@ class TtcpServerConnection : public std::enable_shared_from_this<TtcpServerConne
muduo::noncopyable
{
public:
TtcpServerConnection(boost::asio::io_service& io_service)
: socket_(io_service), count_(0), payload_(NULL), ack_(0)
TtcpServerConnection(boost::asio::executor executor)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why pass by value not by const-reference?
The future readers and maintainers will have the same question here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your reply. I've pushed a new commit to fix this. Apparently, const-reference is a better choice here.
I fully understand that the PR will make the older version fail to build. So, whether a PR (with the latest commit) is merged depends on you. If not, maybe I should close the PR and leave it to the issue #429 to help others who want to use new version Boost.asio.

@chenshuo
Copy link
Owner

Can you make it work for both old and new Boost versions by checking the BOOST_VERSION macro?

@tan-wei
Copy link
Contributor Author

tan-wei commented Apr 28, 2020

OK. A new commit is pushed in my repo. Don't know whether git rebase is required to make git history clear.

@chenshuo chenshuo merged commit 52840b8 into chenshuo:cpp17 Apr 28, 2020
chenshuo pushed a commit that referenced this pull request Apr 28, 2020
* Fix deprecated API in Boost.Asio
* Use BOOST_VERSION macro to make it work for both old and new Boost versions

Cherry-pick: 52840b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants