Skip to content

Commit a8c4f75

Browse files
committed
Move any_adapter
1 parent d182276 commit a8c4f75

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

include/boost/redis/connection.hpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#ifndef BOOST_REDIS_CONNECTION_HPP
88
#define BOOST_REDIS_CONNECTION_HPP
99

10-
#include <boost/redis/any_adapter.hpp>
10+
#include "boost/redis/request.hpp"
11+
#include <boost/redis/adapter/any_adapter.hpp>
1112
#include <boost/redis/detail/connection_base.hpp>
1213
#include <boost/redis/logger.hpp>
1314
#include <boost/redis/config.hpp>
@@ -18,7 +19,6 @@
1819
#include <boost/asio/any_completion_handler.hpp>
1920

2021
#include <chrono>
21-
#include <memory>
2222
#include <limits>
2323

2424
namespace boost::redis {
@@ -412,7 +412,12 @@ class connection {
412412
template <class CompletionToken>
413413
auto async_exec(request const& req, any_adapter adapter, CompletionToken token)
414414
{
415-
return impl_.async_exec(req, std::move(adapter), std::move(token));
415+
return asio::async_initiate<
416+
CompletionToken, void(boost::system::error_code)>(
417+
[](auto handler, connection* self, request const* req, any_adapter adapter)
418+
{
419+
self->async_exec_impl(*req, std::move(adapter), std::move(handler));
420+
}, token, this, &req, std::move(adapter));
416421
}
417422

418423
/// Calls `boost::redis::basic_connection::cancel`.
@@ -453,6 +458,12 @@ class connection {
453458
config const& cfg,
454459
logger l,
455460
asio::any_completion_handler<void(boost::system::error_code)> token);
461+
462+
void
463+
async_exec_impl(
464+
request const& req,
465+
any_adapter adapter,
466+
asio::any_completion_handler<void(boost::system::error_code)> token);
456467

457468
basic_connection<executor_type> impl_;
458469
};

include/boost/redis/detail/connection_base.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifndef BOOST_REDIS_CONNECTION_BASE_HPP
88
#define BOOST_REDIS_CONNECTION_BASE_HPP
99

10-
#include <boost/redis/any_adapter.hpp>
10+
#include <boost/redis/adapter/any_adapter.hpp>
1111
#include <boost/redis/adapter/adapt.hpp>
1212
#include <boost/redis/detail/helper.hpp>
1313
#include <boost/redis/error.hpp>
@@ -443,7 +443,7 @@ class connection_base {
443443
}
444444

445445
template <class CompletionToken>
446-
auto async_exec(request const& req, any_adapter adapter, CompletionToken token)
446+
auto async_exec(request const& req, any_adapter adapter, CompletionToken&& token)
447447
{
448448
auto adapter_impl = std::move(adapter).get_impl();
449449
BOOST_ASSERT_MSG(req.get_expected_responses() <= adapter_impl.supported_response_size, "Request and response have incompatible sizes.");
@@ -456,12 +456,6 @@ class connection_base {
456456
>(exec_op<this_type>{this, info}, token, writer_timer_);
457457
}
458458

459-
template <class Response, class CompletionToken>
460-
auto async_exec(request const& req, Response& resp, CompletionToken token)
461-
{
462-
return async_exec(req, any_adapter(resp), std::forward<CompletionToken>(token));
463-
}
464-
465459
template <class Response, class CompletionToken>
466460
[[deprecated("Set the response with set_receive_response and use the other overload.")]]
467461
auto async_receive(Response& response, CompletionToken token)

include/boost/redis/impl/connection.ipp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ connection::async_run_impl(
3131
impl_.async_run(cfg, l, std::move(token));
3232
}
3333

34+
void
35+
connection::async_exec_impl(
36+
request const& req,
37+
any_adapter adapter,
38+
asio::any_completion_handler<void(boost::system::error_code)> token)
39+
{
40+
impl_.async_exec(req, std::move(adapter), std::move(token));
41+
}
42+
3443
void connection::cancel(operation op)
3544
{
3645
impl_.cancel(op);

0 commit comments

Comments
 (0)