Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:39:14

0001 //
0002 // Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 
0008 #ifndef BOOST_MYSQL_DETAIL_INITIATION_BASE_HPP
0009 #define BOOST_MYSQL_DETAIL_INITIATION_BASE_HPP
0010 
0011 #include <boost/mysql/with_diagnostics.hpp>
0012 
0013 #include <boost/asio/any_io_executor.hpp>
0014 #include <boost/asio/associator.hpp>
0015 #include <boost/asio/deferred.hpp>
0016 
0017 #include <type_traits>
0018 
0019 namespace boost {
0020 namespace mysql {
0021 namespace detail {
0022 
0023 struct executor_with_default : asio::any_io_executor
0024 {
0025     using default_completion_token_type = with_diagnostics_t<asio::deferred_t>;
0026 
0027     template <
0028         typename InnerExecutor1,
0029         class = typename std::enable_if<!std::is_same<InnerExecutor1, executor_with_default>::value>::type>
0030     executor_with_default(const InnerExecutor1& ex) noexcept : asio::any_io_executor(ex)
0031     {
0032     }
0033 };
0034 
0035 // Base class for initiation objects. Includes a bound executor, so they're compatible
0036 // with asio::cancel_after and similar. The bound executor has our default completion token.
0037 // Use only in the ops that should use this token.
0038 struct initiation_base
0039 {
0040     executor_with_default ex;
0041 
0042     initiation_base(asio::any_io_executor ex) noexcept : ex(std::move(ex)) {}
0043 
0044     using executor_type = executor_with_default;
0045     const executor_type& get_executor() const noexcept { return ex; }
0046 };
0047 
0048 }  // namespace detail
0049 }  // namespace mysql
0050 
0051 }  // namespace boost
0052 
0053 #endif