8#include <boost/redis/connection.hpp>
9#include <boost/redis/request.hpp>
10#include <boost/asio/deferred.hpp>
11#include <boost/asio/detached.hpp>
12#include <boost/asio/use_future.hpp>
16using namespace std::chrono_literals;
21class sync_connection {
25 , conn_{std::make_shared<connection>(ioc_)}
37 thread_ = std::thread{[
this, cfg]() {
38 conn_->async_run(cfg, {}, asio::detached);
45 asio::dispatch(ioc_, [
this]() { conn_->cancel(); });
48 template <
class Response>
49 auto exec(request
const& req, Response& resp)
52 conn_->get_executor(),
53 asio::deferred([
this, &req, &resp]() { return conn_->async_exec(req, resp, asio::deferred); }))
54 (asio::use_future).get();
58 asio::io_context ioc_{1};
59 std::shared_ptr<connection> conn_;
@ exec
Refers to connection::async_exec operations.
@ run
Refers to connection::async_run operations.