Skip to content

Replaces asio::post by async_immediate for immediate completions #37

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

Merged
merged 2 commits into from
Jul 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/boost/http_io/detail/except.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define BOOST_HTTP_IO_DETAIL_EXCEPT_HPP

#include <boost/assert/source_location.hpp>
#include <boost/http_io/detail/config.hpp>

namespace boost {
namespace http_io {
Expand Down
23 changes: 7 additions & 16 deletions include/boost/http_io/impl/read.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
#include <boost/asio/append.hpp>
#include <boost/asio/compose.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/immediate.hpp>
#include <boost/assert.hpp>
#include <type_traits>

namespace boost {
namespace http_io {
Expand Down Expand Up @@ -57,13 +56,9 @@ class read_header_op
{
BOOST_ASIO_HANDLER_LOCATION((
__FILE__, __LINE__,
"post"));
asio::post(
stream_.get_executor(),
asio::append(
std::move(self),
ec,
0));
"immediate"));
asio::async_immediate(
self.get_io_executor(), std::move(self));
}
goto upcall;
}
Expand Down Expand Up @@ -145,13 +140,9 @@ class read_body_op
{
BOOST_ASIO_HANDLER_LOCATION((
__FILE__, __LINE__,
"post"));
asio::post(
stream_.get_executor(),
asio::append(
std::move(self),
ec,
0));
"immediate"));
asio::async_immediate(
self.get_io_executor(), asio::append(std::move(self), ec));
}
goto upcall;
}
Expand Down
26 changes: 6 additions & 20 deletions include/boost/http_io/impl/write.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#include <boost/asio/buffer.hpp>
#include <boost/asio/compose.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/immediate.hpp>
#include <boost/system/error_code.hpp>
#include <boost/system/result.hpp>
#include <iterator>
#include <boost/http_proto/serializer.hpp>

namespace boost {
namespace http_io {
Expand All @@ -43,20 +43,12 @@ class write_some_op
{
}

template<class Self>
void
operator()(Self& self)
{
(*this)(self, {}, 0, true);
}

template<class Self>
void
operator()(
Self& self,
system::error_code ec,
std::size_t bytes_transferred,
bool do_post = false)
system::error_code ec = {},
std::size_t bytes_transferred = {})
{
system::result<buffers_type> rv;

Expand All @@ -66,19 +58,13 @@ class write_some_op
if(! rv)
{
ec = rv.error();
if(! do_post)
goto upcall;
BOOST_ASIO_CORO_YIELD
{
BOOST_ASIO_HANDLER_LOCATION((
__FILE__, __LINE__,
"http_io::write_some_op"));
asio::post(
dest_.get_executor(),
asio::append(
std::move(self),
ec,
bytes_transferred));
asio::async_immediate(
self.get_io_executor(), asio::append(std::move(self), ec));
}
goto upcall;
}
Expand Down
Loading