From 12cc10f8bb7c9db891dd70fd87569b33da5916c1 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 22 Mar 2018 20:13:39 -0700 Subject: [PATCH] Revert "Tidy up calls to post()" This reverts commit 5eaa2be85e99352bac69e37164febb539bb69a61. --- CHANGELOG.md | 6 ++++ example/common/detect_ssl.hpp | 1 + .../beast/core/impl/buffered_read_stream.ipp | 1 + include/boost/beast/http/impl/read.ipp | 11 +++---- include/boost/beast/http/impl/write.ipp | 3 ++ include/boost/beast/websocket/impl/accept.ipp | 1 + include/boost/beast/websocket/impl/close.ipp | 13 +++++--- include/boost/beast/websocket/impl/ping.ipp | 4 ++- include/boost/beast/websocket/impl/read.ipp | 33 ++++++++++++------- .../boost/beast/websocket/impl/teardown.ipp | 3 +- include/boost/beast/websocket/impl/write.ipp | 11 +++---- 11 files changed, 56 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33933b24..bf481e2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 167: + +* Revert: Tidy up calls to post() + +-------------------------------------------------------------------------------- + Version 166: * Use boost::is_convertible as a workaround diff --git a/example/common/detect_ssl.hpp b/example/common/detect_ssl.hpp index 388b9cce..6fd1d654 100644 --- a/example/common/detect_ssl.hpp +++ b/example/common/detect_ssl.hpp @@ -413,6 +413,7 @@ operator()(boost::beast::error_code ec, std::size_t bytes_transferred) // original handler. BOOST_ASIO_CORO_YIELD boost::asio::post( + stream_.get_executor(), beast::bind_handler(std::move(*this), ec, 0)); } else diff --git a/include/boost/beast/core/impl/buffered_read_stream.ipp b/include/boost/beast/core/impl/buffered_read_stream.ipp index 76f33f77..1ae76b4d 100644 --- a/include/boost/beast/core/impl/buffered_read_stream.ipp +++ b/include/boost/beast/core/impl/buffered_read_stream.ipp @@ -121,6 +121,7 @@ read_some_op::operator()( } step_ = 3; return boost::asio::post( + s_.get_executor(), bind_handler(std::move(*this), ec, 0)); case 1: diff --git a/include/boost/beast/http/impl/read.ipp b/include/boost/beast/http/impl/read.ipp index e669a2fd..28ff0a3c 100644 --- a/include/boost/beast/http/impl/read.ipp +++ b/include/boost/beast/http/impl/read.ipp @@ -170,11 +170,10 @@ operator()( upcall: if(! cont_) - { - BOOST_ASIO_CORO_YIELD - boost::asio::post( - bind_handler(std::move(*this), ec)); - } + return boost::asio::post( + s_.get_executor(), + bind_handler(std::move(h_), + ec, bytes_transferred_)); h_(ec, bytes_transferred_); } } @@ -291,7 +290,7 @@ operator()( if(Condition{}(p_)) { BOOST_ASIO_CORO_YIELD - boost::asio::post( + boost::asio::post(s_.get_executor(), bind_handler(std::move(*this), ec)); goto upcall; } diff --git a/include/boost/beast/http/impl/write.ipp b/include/boost/beast/http/impl/write.ipp index 833bab64..af31cd9b 100644 --- a/include/boost/beast/http/impl/write.ipp +++ b/include/boost/beast/http/impl/write.ipp @@ -140,6 +140,7 @@ operator()() { BOOST_ASSERT(! f.invoked); return boost::asio::post( + s_.get_executor(), bind_handler(std::move(*this), ec, 0)); } if(f.invoked) @@ -152,6 +153,7 @@ operator()() BOOST_ASSERT(sr_.is_done()); } return boost::asio::post( + s_.get_executor(), bind_handler(std::move(*this), ec, 0)); } @@ -282,6 +284,7 @@ operator()( { state_ = 1; return boost::asio::post( + s_.get_executor(), bind_handler(std::move(*this), ec, 0)); } state_ = 2; diff --git a/include/boost/beast/websocket/impl/accept.ipp b/include/boost/beast/websocket/impl/accept.ipp index f000f3bf..9daf7b31 100644 --- a/include/boost/beast/websocket/impl/accept.ipp +++ b/include/boost/beast/websocket/impl/accept.ipp @@ -265,6 +265,7 @@ operator()(error_code ec, std::size_t) { BOOST_ASIO_CORO_YIELD boost::asio::post( + d.ws.get_executor(), bind_handler(std::move(*this), ec)); } else diff --git a/include/boost/beast/websocket/impl/close.ipp b/include/boost/beast/websocket/impl/close.ipp index da3793c8..7b0e1ff6 100644 --- a/include/boost/beast/websocket/impl/close.ipp +++ b/include/boost/beast/websocket/impl/close.ipp @@ -152,7 +152,8 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post(std::move(*this)); + boost::asio::post( + d.ws.get_executor(), std::move(*this)); BOOST_ASSERT(d.ws.wr_block_.is_locked(this)); // Make sure the stream is open @@ -195,7 +196,8 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post(std::move(*this)); + boost::asio::post( + d.ws.get_executor(), std::move(*this)); BOOST_ASSERT(d.ws.rd_block_.is_locked(this)); // Make sure the stream is open @@ -301,9 +303,10 @@ operator()( d.ws.paused_wr_.maybe_invoke(); if(! d.cont) { - BOOST_ASIO_CORO_YIELD - boost::asio::post( - bind_handler(std::move(*this), ec)); + auto& ws = d.ws; + return boost::asio::post( + ws.stream_.get_executor(), + bind_handler(d_.release_handler(), ec)); } d_.invoke(ec); } diff --git a/include/boost/beast/websocket/impl/ping.ipp b/include/boost/beast/websocket/impl/ping.ipp index 40fb577a..c7deb9c3 100644 --- a/include/boost/beast/websocket/impl/ping.ipp +++ b/include/boost/beast/websocket/impl/ping.ipp @@ -135,6 +135,7 @@ operator()(error_code ec, std::size_t) { BOOST_ASIO_CORO_YIELD boost::asio::post( + d.ws.get_executor(), bind_handler(std::move(*this), ec)); goto upcall; } @@ -150,7 +151,8 @@ operator()(error_code ec, std::size_t) // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post(std::move(*this)); + boost::asio::post( + d.ws.get_executor(), std::move(*this)); BOOST_ASSERT(d.ws.wr_block_.is_locked(this)); // Make sure the stream is open diff --git a/include/boost/beast/websocket/impl/read.ipp b/include/boost/beast/websocket/impl/read.ipp index 686f26f9..1dfbd01e 100644 --- a/include/boost/beast/websocket/impl/read.ipp +++ b/include/boost/beast/websocket/impl/read.ipp @@ -196,7 +196,8 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post(std::move(*this)); + boost::asio::post( + ws_.get_executor(), std::move(*this)); BOOST_ASSERT(ws_.rd_block_.is_locked(this)); // The only way to get read blocked is if @@ -277,7 +278,9 @@ operator()( if(! cont_) { BOOST_ASIO_CORO_YIELD - boost::asio::post(std::move(*this)); + boost::asio::post( + ws_.get_executor(), + std::move(*this)); BOOST_ASSERT(cont_); } } @@ -319,7 +322,8 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post(std::move(*this)); + boost::asio::post( + ws_.get_executor(), std::move(*this)); BOOST_ASSERT(ws_.wr_block_.is_locked(this)); // Make sure the stream is open @@ -350,7 +354,9 @@ operator()( if(! cont_) { BOOST_ASIO_CORO_YIELD - boost::asio::post(std::move(*this)); + boost::asio::post( + ws_.get_executor(), + std::move(*this)); BOOST_ASSERT(cont_); } } @@ -374,7 +380,9 @@ operator()( if(! cont_) { BOOST_ASIO_CORO_YIELD - boost::asio::post(std::move(*this)); + boost::asio::post( + ws_.get_executor(), + std::move(*this)); BOOST_ASSERT(cont_); } } @@ -630,7 +638,8 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post(std::move(*this)); + boost::asio::post( + ws_.get_executor(), std::move(*this)); BOOST_ASSERT(ws_.wr_block_.is_locked(this)); // Make sure the stream is open @@ -691,11 +700,10 @@ operator()( ws_.paused_ping_.maybe_invoke() || ws_.paused_wr_.maybe_invoke(); if(! cont_) - { - BOOST_ASIO_CORO_YIELD - boost::asio::post( - bind_handler(std::move(*this), ec)); - } + return boost::asio::post( + ws_.stream_.get_executor(), + bind_handler(std::move(h_), + ec, bytes_written_)); h_(ec, bytes_written_); } } @@ -806,8 +814,9 @@ operator()( { BOOST_ASIO_CORO_YIELD boost::asio::post( + ws_.get_executor(), bind_handler(std::move(*this), - error::buffer_overflow)); + error::buffer_overflow, 0)); break; } BOOST_ASIO_CORO_YIELD diff --git a/include/boost/beast/websocket/impl/teardown.ipp b/include/boost/beast/websocket/impl/teardown.ipp index d0cbf60a..add6b277 100644 --- a/include/boost/beast/websocket/impl/teardown.ipp +++ b/include/boost/beast/websocket/impl/teardown.ipp @@ -113,7 +113,8 @@ operator()(error_code ec, std::size_t bytes_transferred) { BOOST_ASIO_CORO_YIELD boost::asio::post( - bind_handler(std::move(*this), ec)); + s_.get_executor(), + bind_handler(std::move(*this), ec, 0)); goto upcall; } for(;;) diff --git a/include/boost/beast/websocket/impl/write.ipp b/include/boost/beast/websocket/impl/write.ipp index fe09b152..d12f2f9e 100644 --- a/include/boost/beast/websocket/impl/write.ipp +++ b/include/boost/beast/websocket/impl/write.ipp @@ -321,7 +321,8 @@ operator()( // Resume BOOST_ASIO_CORO_YIELD - boost::asio::post(std::move(*this)); + boost::asio::post( + ws_.get_executor(), std::move(*this)); BOOST_ASSERT(ws_.wr_block_.is_locked(this)); // Make sure the stream is open @@ -568,11 +569,9 @@ operator()( ws_.paused_rd_.maybe_invoke() || ws_.paused_ping_.maybe_invoke(); if(! cont_) - { - BOOST_ASIO_CORO_YIELD - boost::asio::post( - bind_handler(std::move(*this), ec)); - } + return boost::asio::post( + ws_.stream_.get_executor(), + bind_handler(std::move(h_), ec, bytes_transferred_)); h_(ec, bytes_transferred_); } }