2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_CORE_DETAIL_STREAM_BASE_HPP
11 #define BOOST_BEAST_CORE_DETAIL_STREAM_BASE_HPP
13 #include <boost/asio/steady_timer.hpp>
14 #include <boost/assert.hpp>
15 #include <boost/core/exchange.hpp>
26 template<class Error, class Endpoint>
29 Error const&, Endpoint const&) const noexcept
37 using clock_type = std::chrono::steady_clock;
38 using time_point = typename
39 std::chrono::steady_clock::time_point;
40 using tick_type = std::uint64_t;
44 net::steady_timer timer; // for timing out
45 tick_type tick = 0; // counts waits
46 bool pending = false; // if op is pending
47 bool timeout = false; // if timed out
49 template<class... Args>
51 op_state(Args&&... args)
52 : timer(std::forward<Args>(args)...)
76 pending_guard(bool& b)
79 // If this assert goes off, it means you are attempting
80 // to issue two of the same asynchronous I/O operation
81 // at the same time, without waiting for the first one
82 // to complete. For example, attempting two simultaneous
83 // calls to async_read_some. Only one pending call of
84 // each I/O type (read and write) is permitted.
91 pending_guard&& other) noexcept
93 , clear_(boost::exchange(
101 BOOST_ASSERT(clear_);
104 // If this assert goes off, it means you are attempting
105 // to issue two of the same asynchronous I/O operation
106 // at the same time, without waiting for the first one
107 // to complete. For example, attempting two simultaneous
108 // calls to async_read_some. Only one pending call of
109 // each I/O type (read and write) is permitted.
118 BOOST_ASSERT(clear_);
125 static time_point never() noexcept
127 return (time_point::max)();
130 static std::size_t constexpr no_limit =
131 (std::numeric_limits<std::size_t>::max)();