2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 // Copyright (c) 2020 Richard Hodges (hodges.r@gmail.com)
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 // Official repository: https://github.com/boostorg/beast
11 #ifndef BOOST_BEAST_TEST_DETAIL_STREAM_STATE_HPP
12 #define BOOST_BEAST_TEST_DETAIL_STREAM_STATE_HPP
14 #include <boost/asio/any_io_executor.hpp>
15 #include <boost/beast/core/detail/config.hpp>
16 #include <boost/beast/_experimental/test/fail_count.hpp>
17 #include <boost/beast/core/detail/service_base.hpp>
18 #include <boost/beast/core/flat_buffer.hpp>
19 #include <boost/smart_ptr/weak_ptr.hpp>
21 #include <condition_variable>
33 struct stream_service_impl
36 std::vector<stream_state*> v_;
40 remove(stream_state& impl);
43 //------------------------------------------------------------------------------
46 : public beast::detail::service_base<stream_service>
48 boost::shared_ptr<detail::stream_service_impl> sp_;
57 stream_service(net::execution_context& ctx);
63 net::any_io_executor exec,
64 test::fail_count* fc) ->
65 boost::shared_ptr<detail::stream_state>;
68 //------------------------------------------------------------------------------
70 struct stream_read_op_base
72 virtual ~stream_read_op_base() = default;
73 virtual void operator()(error_code ec) = 0;
76 //------------------------------------------------------------------------------
78 enum class stream_status
84 //------------------------------------------------------------------------------
88 net::any_io_executor exec;
89 boost::weak_ptr<stream_service_impl> wp;
92 std::condition_variable cv;
93 std::unique_ptr<stream_read_op_base> op;
94 stream_status code = stream_status::ok;
95 fail_count* fc = nullptr;
96 std::size_t nread = 0;
97 std::size_t nread_bytes = 0;
98 std::size_t nwrite = 0;
99 std::size_t nwrite_bytes = 0;
100 std::size_t read_max =
101 (std::numeric_limits<std::size_t>::max)();
102 std::size_t write_max =
103 (std::numeric_limits<std::size_t>::max)();
107 net::any_io_executor exec_,
108 boost::weak_ptr<stream_service_impl> wp_,
134 #ifdef BOOST_BEAST_HEADER_ONLY
135 #include <boost/beast/_experimental/test/detail/stream_state.ipp>
138 #endif // BOOST_BEAST_TEST_DETAIL_STREAM_STATE_HPP