Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/mysql/impl/internal/sansio/ping.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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_IMPL_INTERNAL_SANSIO_PING_HPP
0009 #define BOOST_MYSQL_IMPL_INTERNAL_SANSIO_PING_HPP
0010 
0011 #include <boost/mysql/diagnostics.hpp>
0012 
0013 #include <boost/mysql/detail/algo_params.hpp>
0014 
0015 #include <boost/mysql/impl/internal/coroutine.hpp>
0016 #include <boost/mysql/impl/internal/protocol/serialization.hpp>
0017 #include <boost/mysql/impl/internal/sansio/connection_state_data.hpp>
0018 
0019 namespace boost {
0020 namespace mysql {
0021 namespace detail {
0022 
0023 class read_ping_response_algo
0024 {
0025     int resume_point_{0};
0026     std::uint8_t seqnum_{0};
0027 
0028 public:
0029     read_ping_response_algo(std::uint8_t seqnum) noexcept : seqnum_(seqnum) {}
0030 
0031     next_action resume(connection_state_data& st, diagnostics& diag, error_code ec)
0032     {
0033         switch (resume_point_)
0034         {
0035         case 0:
0036 
0037             // Issue a read
0038             BOOST_MYSQL_YIELD(resume_point_, 1, st.read(seqnum_))
0039             if (ec)
0040                 return ec;
0041 
0042             // Process the OK packet and done
0043             ec = st.deserialize_ok(diag);
0044         }
0045 
0046         return ec;
0047     }
0048 };
0049 
0050 inline run_pipeline_algo_params setup_ping_pipeline(connection_state_data& st)
0051 {
0052     // The ping request is fixed size and small. No buffer limit is enforced on it.
0053     st.write_buffer.clear();
0054     st.shared_pipeline_stages[0] = {
0055         pipeline_stage_kind::ping,
0056         serialize_top_level_checked(ping_command{}, st.write_buffer),
0057         {}
0058     };
0059     return {
0060         st.write_buffer,
0061         {st.shared_pipeline_stages.data(), 1},
0062         nullptr
0063     };
0064 }
0065 
0066 }  // namespace detail
0067 }  // namespace mysql
0068 }  // namespace boost
0069 
0070 #endif