Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-17 09:00:18

0001 //
0002 // Copyright (c) 2025 Marcelo Zimbres Silva (mzimbres@gmail.com),
0003 // Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
0004 //
0005 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0006 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 
0009 #ifndef BOOST_REDIS_RUN_FSM_HPP
0010 #define BOOST_REDIS_RUN_FSM_HPP
0011 
0012 #include <boost/asio/cancellation_type.hpp>
0013 #include <boost/system/error_code.hpp>
0014 
0015 // Sans-io algorithm for async_run, as a finite state machine
0016 
0017 namespace boost::redis::detail {
0018 
0019 // Forward decls
0020 struct connection_state;
0021 
0022 // What should we do next?
0023 enum class run_action_type
0024 {
0025    done,                   // Call the final handler
0026    immediate,              // Call asio::async_immediate
0027    connect,                // Transport connection establishment
0028    parallel_group,         // Run the reader, writer and friends
0029    cancel_receive,         // Cancel the receiver channel
0030    wait_for_reconnection,  // Sleep for the reconnection period
0031 };
0032 
0033 struct run_action {
0034    run_action_type type;
0035    system::error_code ec;
0036 
0037    run_action(run_action_type type) noexcept
0038    : type{type}
0039    { }
0040 
0041    run_action(system::error_code ec) noexcept
0042    : type{run_action_type::done}
0043    , ec{ec}
0044    { }
0045 };
0046 
0047 class run_fsm {
0048    int resume_point_{0};
0049    system::error_code stored_ec_;
0050 
0051 public:
0052    run_fsm() = default;
0053 
0054    run_action resume(
0055       connection_state& st,
0056       system::error_code ec,
0057       asio::cancellation_type_t cancel_state);
0058 };
0059 
0060 }  // namespace boost::redis::detail
0061 
0062 #endif  // BOOST_REDIS_CONNECTOR_HPP