21 #include <boost/asio.hpp>
46 using interface::TcpSocketInterface;
55 std::variant<memory::PooledBuffer, std::vector<uint8_t>, std::shared_ptr<const std::vector<uint8_t>>>;
59 int idle_timeout_ms = 0);
61 TcpServerSession(net::io_context& ioc, std::unique_ptr<interface::TcpSocketInterface> socket,
63 int idle_timeout_ms = 0);
67 void async_write_move(std::vector<uint8_t>&& data);
68 void async_write_shared(std::shared_ptr<
const std::vector<uint8_t>> data);
80 void report_backpressure(
size_t queued_bytes);
81 void reset_idle_timer();
84 net::io_context& ioc_;
85 net::strand<net::io_context::executor_type> strand_;
86 net::steady_timer idle_timer_;
87 std::unique_ptr<interface::TcpSocketInterface> socket_;
88 std::array<uint8_t, common::constants::DEFAULT_READ_BUFFER_SIZE> rx_{};
89 std::deque<BufferVariant> tx_;
90 std::optional<BufferVariant> current_write_buffer_;
91 bool writing_ =
false;
92 size_t queue_bytes_ = 0;
96 bool backpressure_active_ =
false;
97 int idle_timeout_ms_ = 0;
100 OnBackpressure on_bp_;
102 std::atomic<bool> alive_{
false};
103 std::atomic<bool> closing_{
false};
104 std::atomic<bool> cleanup_done_{
false};
std::function< void(memory::ConstByteSpan)> OnBytes
std::function< void(size_t)> OnBackpressure
A C++17 compatible span-like class for safe array access.
interface::Channel::OnBackpressure OnBackpressure
std::function< void()> OnClose
interface::Channel::OnBytes OnBytes
std::variant< memory::PooledBuffer, std::vector< uint8_t >, std::shared_ptr< const std::vector< uint8_t > >> BufferVariant
constexpr size_t DEFAULT_BACKPRESSURE_THRESHOLD