File indexing completed on 2025-04-19 08:33:52
0001
0002
0003
0004
0005
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/detail/algo_params.hpp>
0012
0013 #include <boost/mysql/impl/internal/coroutine.hpp>
0014 #include <boost/mysql/impl/internal/protocol/serialization.hpp>
0015 #include <boost/mysql/impl/internal/sansio/connection_state_data.hpp>
0016
0017 namespace boost {
0018 namespace mysql {
0019 namespace detail {
0020
0021 class read_ping_response_algo
0022 {
0023 int resume_point_{0};
0024 diagnostics* diag_;
0025 std::uint8_t seqnum_{0};
0026
0027 public:
0028 read_ping_response_algo(diagnostics* diag, std::uint8_t seqnum) noexcept : diag_(diag), seqnum_(seqnum) {}
0029
0030 next_action resume(connection_state_data& st, error_code ec)
0031 {
0032 switch (resume_point_)
0033 {
0034 case 0:
0035
0036
0037 BOOST_MYSQL_YIELD(resume_point_, 1, st.read(seqnum_))
0038 if (ec)
0039 return ec;
0040
0041
0042 return st.deserialize_ok(*diag_);
0043 }
0044 return next_action();
0045 }
0046 };
0047
0048 inline run_pipeline_algo_params setup_ping_pipeline(connection_state_data& st, ping_algo_params params)
0049 {
0050 st.write_buffer.clear();
0051 auto seqnum = serialize_top_level(ping_command{}, st.write_buffer);
0052 st.shared_pipeline_stages[0] = {pipeline_stage_kind::ping, seqnum, {}};
0053 return {
0054 params.diag,
0055 st.write_buffer,
0056 {st.shared_pipeline_stages.data(), 1},
0057 nullptr
0058 };
0059 }
0060
0061 }
0062 }
0063 }
0064
0065 #endif