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)...)
70 pending_guard(bool& b)
73 // If this assert goes off, it means you are attempting
74 // to issue two of the same asynchronous I/O operation
75 // at the same time, without waiting for the first one
76 // to complete. For example, attempting two simultaneous
77 // calls to async_read_some. Only one pending call of
78 // each I/O type (read and write) is permitted.
85 pending_guard&& other) noexcept
87 , clear_(boost::exchange(
101 static time_point never() noexcept
103 return (time_point::max)();
106 static std::size_t constexpr no_limit =
107 (std::numeric_limits<std::size_t>::max)();