src/cxx_supportlib/vendor-modified/boost/asio/impl/read.hpp in passenger-6.0.11 vs src/cxx_supportlib/vendor-modified/boost/asio/impl/read.hpp in passenger-6.0.12
- old
+ new
@@ -14,15 +14,15 @@
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <algorithm>
-#include <boost/asio/associated_allocator.hpp>
-#include <boost/asio/associated_executor.hpp>
+#include <boost/asio/associator.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/completion_condition.hpp>
#include <boost/asio/detail/array_fwd.hpp>
+#include <boost/asio/detail/base_from_cancellation_state.hpp>
#include <boost/asio/detail/base_from_completion_cond.hpp>
#include <boost/asio/detail/bind_handler.hpp>
#include <boost/asio/detail/consuming_buffers.hpp>
#include <boost/asio/detail/dependent_type.hpp>
#include <boost/asio/detail/handler_alloc_helpers.hpp>
@@ -322,55 +322,61 @@
{
template <typename AsyncReadStream, typename MutableBufferSequence,
typename MutableBufferIterator, typename CompletionCondition,
typename ReadHandler>
class read_op
- : detail::base_from_completion_cond<CompletionCondition>
+ : public base_from_cancellation_state<ReadHandler>,
+ base_from_completion_cond<CompletionCondition>
{
public:
read_op(AsyncReadStream& stream, const MutableBufferSequence& buffers,
CompletionCondition& completion_condition, ReadHandler& handler)
- : detail::base_from_completion_cond<
- CompletionCondition>(completion_condition),
+ : base_from_cancellation_state<ReadHandler>(
+ handler, enable_partial_cancellation()),
+ base_from_completion_cond<CompletionCondition>(completion_condition),
stream_(stream),
buffers_(buffers),
start_(0),
handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
{
}
#if defined(BOOST_ASIO_HAS_MOVE)
read_op(const read_op& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
+ : base_from_cancellation_state<ReadHandler>(other),
+ base_from_completion_cond<CompletionCondition>(other),
stream_(other.stream_),
buffers_(other.buffers_),
start_(other.start_),
handler_(other.handler_)
{
}
read_op(read_op&& other)
- : detail::base_from_completion_cond<CompletionCondition>(
- BOOST_ASIO_MOVE_CAST(detail::base_from_completion_cond<
+ : base_from_cancellation_state<ReadHandler>(
+ BOOST_ASIO_MOVE_CAST(base_from_cancellation_state<
+ ReadHandler>)(other)),
+ base_from_completion_cond<CompletionCondition>(
+ BOOST_ASIO_MOVE_CAST(base_from_completion_cond<
CompletionCondition>)(other)),
stream_(other.stream_),
buffers_(BOOST_ASIO_MOVE_CAST(buffers_type)(other.buffers_)),
start_(other.start_),
handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
{
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
- void operator()(const boost::system::error_code& ec,
+ void operator()(boost::system::error_code ec,
std::size_t bytes_transferred, int start = 0)
{
std::size_t max_size;
switch (start_ = start)
{
case 1:
max_size = this->check_for_completion(ec, buffers_.total_consumed());
- do
+ for (;;)
{
{
BOOST_ASIO_HANDLER_LOCATION((__FILE__, __LINE__, "async_read"));
stream_.async_read_some(buffers_.prepare(max_size),
BOOST_ASIO_MOVE_CAST(read_op)(*this));
@@ -378,13 +384,22 @@
return; default:
buffers_.consume(bytes_transferred);
if ((!ec && bytes_transferred == 0) || buffers_.empty())
break;
max_size = this->check_for_completion(ec, buffers_.total_consumed());
- } while (max_size > 0);
+ if (max_size == 0)
+ break;
+ if (this->cancelled() != cancellation_type::none)
+ {
+ ec = error::operation_aborted;
+ break;
+ }
+ }
- handler_(ec, buffers_.total_consumed());
+ BOOST_ASIO_MOVE_OR_LVALUE(ReadHandler)(handler_)(
+ static_cast<const boost::system::error_code&>(ec),
+ static_cast<const std::size_t&>(buffers_.total_consumed()));
}
}
//private:
typedef boost::asio::detail::consuming_buffers<mutable_buffer,
@@ -521,49 +536,29 @@
};
} // namespace detail
#if !defined(GENERATING_DOCUMENTATION)
-template <typename AsyncReadStream, typename MutableBufferSequence,
+template <template <typename, typename> class Associator,
+ typename AsyncReadStream, typename MutableBufferSequence,
typename MutableBufferIterator, typename CompletionCondition,
- typename ReadHandler, typename Allocator>
-struct associated_allocator<
+ typename ReadHandler, typename DefaultCandidate>
+struct associator<Associator,
detail::read_op<AsyncReadStream, MutableBufferSequence,
MutableBufferIterator, CompletionCondition, ReadHandler>,
- Allocator>
+ DefaultCandidate>
+ : Associator<ReadHandler, DefaultCandidate>
{
- typedef typename associated_allocator<ReadHandler, Allocator>::type type;
-
- static type get(
+ static typename Associator<ReadHandler, DefaultCandidate>::type get(
const detail::read_op<AsyncReadStream, MutableBufferSequence,
MutableBufferIterator, CompletionCondition, ReadHandler>& h,
- const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
+ const DefaultCandidate& c = DefaultCandidate()) BOOST_ASIO_NOEXCEPT
{
- return associated_allocator<ReadHandler, Allocator>::get(h.handler_, a);
+ return Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c);
}
};
-template <typename AsyncReadStream, typename MutableBufferSequence,
- typename MutableBufferIterator, typename CompletionCondition,
- typename ReadHandler, typename Executor>
-struct associated_executor<
- detail::read_op<AsyncReadStream, MutableBufferSequence,
- MutableBufferIterator, CompletionCondition, ReadHandler>,
- Executor>
- : detail::associated_executor_forwarding_base<ReadHandler, Executor>
-{
- typedef typename associated_executor<ReadHandler, Executor>::type type;
-
- static type get(
- const detail::read_op<AsyncReadStream, MutableBufferSequence,
- MutableBufferIterator, CompletionCondition, ReadHandler>& h,
- const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
- {
- return associated_executor<ReadHandler, Executor>::get(h.handler_, ex);
- }
-};
-
#endif // !defined(GENERATING_DOCUMENTATION)
template <typename AsyncReadStream,
typename MutableBufferSequence, typename CompletionCondition,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
@@ -605,52 +600,58 @@
namespace detail
{
template <typename AsyncReadStream, typename DynamicBuffer_v1,
typename CompletionCondition, typename ReadHandler>
class read_dynbuf_v1_op
- : detail::base_from_completion_cond<CompletionCondition>
+ : public base_from_cancellation_state<ReadHandler>,
+ base_from_completion_cond<CompletionCondition>
{
public:
template <typename BufferSequence>
read_dynbuf_v1_op(AsyncReadStream& stream,
BOOST_ASIO_MOVE_ARG(BufferSequence) buffers,
CompletionCondition& completion_condition, ReadHandler& handler)
- : detail::base_from_completion_cond<
- CompletionCondition>(completion_condition),
+ : base_from_cancellation_state<ReadHandler>(
+ handler, enable_partial_cancellation()),
+ base_from_completion_cond<CompletionCondition>(completion_condition),
stream_(stream),
buffers_(BOOST_ASIO_MOVE_CAST(BufferSequence)(buffers)),
start_(0),
total_transferred_(0),
handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))
{
}
#if defined(BOOST_ASIO_HAS_MOVE)
read_dynbuf_v1_op(const read_dynbuf_v1_op& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
+ : base_from_cancellation_state<ReadHandler>(other),
+ base_from_completion_cond<CompletionCondition>(other),
stream_(other.stream_),
buffers_(other.buffers_),
start_(other.start_),
total_transferred_(other.total_transferred_),
handler_(other.handler_)
{
}
read_dynbuf_v1_op(read_dynbuf_v1_op&& other)
- : detail::base_from_completion_cond<CompletionCondition>(
- BOOST_ASIO_MOVE_CAST(detail::base_from_completion_cond<
+ : base_from_cancellation_state<ReadHandler>(
+ BOOST_ASIO_MOVE_CAST(base_from_cancellation_state<
+ ReadHandler>)(other)),
+ base_from_completion_cond<CompletionCondition>(
+ BOOST_ASIO_MOVE_CAST(base_from_completion_cond<
CompletionCondition>)(other)),
stream_(other.stream_),
buffers_(BOOST_ASIO_MOVE_CAST(DynamicBuffer_v1)(other.buffers_)),
start_(other.start_),
total_transferred_(other.total_transferred_),
handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
{
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
- void operator()(const boost::system::error_code& ec,
+ void operator()(boost::system::error_code ec,
std::size_t bytes_transferred, int start = 0)
{
std::size_t max_size, bytes_available;
switch (start_ = start)
{
@@ -677,13 +678,20 @@
buffers_.capacity() - buffers_.size()),
std::min<std::size_t>(max_size,
buffers_.max_size() - buffers_.size()));
if ((!ec && bytes_transferred == 0) || bytes_available == 0)
break;
+ if (this->cancelled() != cancellation_type::none)
+ {
+ ec = error::operation_aborted;
+ break;
+ }
}
- handler_(ec, static_cast<const std::size_t&>(total_transferred_));
+ BOOST_ASIO_MOVE_OR_LVALUE(ReadHandler)(handler_)(
+ static_cast<const boost::system::error_code&>(ec),
+ static_cast<const std::size_t&>(total_transferred_));
}
}
//private:
AsyncReadStream& stream_;
@@ -804,47 +812,29 @@
};
} // namespace detail
#if !defined(GENERATING_DOCUMENTATION)
-template <typename AsyncReadStream, typename DynamicBuffer_v1,
- typename CompletionCondition, typename ReadHandler, typename Allocator>
-struct associated_allocator<
+template <template <typename, typename> class Associator,
+ typename AsyncReadStream, typename DynamicBuffer_v1,
+ typename CompletionCondition, typename ReadHandler,
+ typename DefaultCandidate>
+struct associator<Associator,
detail::read_dynbuf_v1_op<AsyncReadStream,
DynamicBuffer_v1, CompletionCondition, ReadHandler>,
- Allocator>
+ DefaultCandidate>
+ : Associator<ReadHandler, DefaultCandidate>
{
- typedef typename associated_allocator<ReadHandler, Allocator>::type type;
-
- static type get(
+ static typename Associator<ReadHandler, DefaultCandidate>::type get(
const detail::read_dynbuf_v1_op<AsyncReadStream,
DynamicBuffer_v1, CompletionCondition, ReadHandler>& h,
- const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
+ const DefaultCandidate& c = DefaultCandidate()) BOOST_ASIO_NOEXCEPT
{
- return associated_allocator<ReadHandler, Allocator>::get(h.handler_, a);
+ return Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c);
}
};
-template <typename AsyncReadStream, typename DynamicBuffer_v1,
- typename CompletionCondition, typename ReadHandler, typename Executor>
-struct associated_executor<
- detail::read_dynbuf_v1_op<AsyncReadStream,
- DynamicBuffer_v1, CompletionCondition, ReadHandler>,
- Executor>
- : detail::associated_executor_forwarding_base<ReadHandler, Executor>
-{
- typedef typename associated_executor<ReadHandler, Executor>::type type;
-
- static type get(
- const detail::read_dynbuf_v1_op<AsyncReadStream,
- DynamicBuffer_v1, CompletionCondition, ReadHandler>& h,
- const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
- {
- return associated_executor<ReadHandler, Executor>::get(h.handler_, ex);
- }
-};
-
#endif // !defined(GENERATING_DOCUMENTATION)
template <typename AsyncReadStream, typename DynamicBuffer_v1,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
std::size_t)) ReadHandler>
@@ -926,19 +916,21 @@
namespace detail
{
template <typename AsyncReadStream, typename DynamicBuffer_v2,
typename CompletionCondition, typename ReadHandler>
class read_dynbuf_v2_op
- : detail::base_from_completion_cond<CompletionCondition>
+ : public base_from_cancellation_state<ReadHandler>,
+ base_from_completion_cond<CompletionCondition>
{
public:
template <typename BufferSequence>
read_dynbuf_v2_op(AsyncReadStream& stream,
BOOST_ASIO_MOVE_ARG(BufferSequence) buffers,
CompletionCondition& completion_condition, ReadHandler& handler)
- : detail::base_from_completion_cond<
- CompletionCondition>(completion_condition),
+ : base_from_cancellation_state<ReadHandler>(
+ handler, enable_partial_cancellation()),
+ base_from_completion_cond<CompletionCondition>(completion_condition),
stream_(stream),
buffers_(BOOST_ASIO_MOVE_CAST(BufferSequence)(buffers)),
start_(0),
total_transferred_(0),
bytes_available_(0),
@@ -946,23 +938,27 @@
{
}
#if defined(BOOST_ASIO_HAS_MOVE)
read_dynbuf_v2_op(const read_dynbuf_v2_op& other)
- : detail::base_from_completion_cond<CompletionCondition>(other),
+ : base_from_cancellation_state<ReadHandler>(other),
+ base_from_completion_cond<CompletionCondition>(other),
stream_(other.stream_),
buffers_(other.buffers_),
start_(other.start_),
total_transferred_(other.total_transferred_),
bytes_available_(other.bytes_available_),
handler_(other.handler_)
{
}
read_dynbuf_v2_op(read_dynbuf_v2_op&& other)
- : detail::base_from_completion_cond<CompletionCondition>(
- BOOST_ASIO_MOVE_CAST(detail::base_from_completion_cond<
+ : base_from_cancellation_state<ReadHandler>(
+ BOOST_ASIO_MOVE_CAST(base_from_cancellation_state<
+ ReadHandler>)(other)),
+ base_from_completion_cond<CompletionCondition>(
+ BOOST_ASIO_MOVE_CAST(base_from_completion_cond<
CompletionCondition>)(other)),
stream_(other.stream_),
buffers_(BOOST_ASIO_MOVE_CAST(DynamicBuffer_v2)(other.buffers_)),
start_(other.start_),
total_transferred_(other.total_transferred_),
@@ -970,11 +966,11 @@
handler_(BOOST_ASIO_MOVE_CAST(ReadHandler)(other.handler_))
{
}
#endif // defined(BOOST_ASIO_HAS_MOVE)
- void operator()(const boost::system::error_code& ec,
+ void operator()(boost::system::error_code ec,
std::size_t bytes_transferred, int start = 0)
{
std::size_t max_size, pos;
switch (start_ = start)
{
@@ -1003,13 +999,20 @@
buffers_.capacity() - buffers_.size()),
std::min<std::size_t>(max_size,
buffers_.max_size() - buffers_.size()));
if ((!ec && bytes_transferred == 0) || bytes_available_ == 0)
break;
+ if (this->cancelled() != cancellation_type::none)
+ {
+ ec = error::operation_aborted;
+ break;
+ }
}
- handler_(ec, static_cast<const std::size_t&>(total_transferred_));
+ BOOST_ASIO_MOVE_OR_LVALUE(ReadHandler)(handler_)(
+ static_cast<const boost::system::error_code&>(ec),
+ static_cast<const std::size_t&>(total_transferred_));
}
}
//private:
AsyncReadStream& stream_;
@@ -1131,43 +1134,25 @@
};
} // namespace detail
#if !defined(GENERATING_DOCUMENTATION)
-template <typename AsyncReadStream, typename DynamicBuffer_v2,
- typename CompletionCondition, typename ReadHandler, typename Allocator>
-struct associated_allocator<
+template <template <typename, typename> class Associator,
+ typename AsyncReadStream, typename DynamicBuffer_v2,
+ typename CompletionCondition, typename ReadHandler,
+ typename DefaultCandidate>
+struct associator<Associator,
detail::read_dynbuf_v2_op<AsyncReadStream,
DynamicBuffer_v2, CompletionCondition, ReadHandler>,
- Allocator>
+ DefaultCandidate>
+ : Associator<ReadHandler, DefaultCandidate>
{
- typedef typename associated_allocator<ReadHandler, Allocator>::type type;
-
- static type get(
+ static typename Associator<ReadHandler, DefaultCandidate>::type get(
const detail::read_dynbuf_v2_op<AsyncReadStream,
DynamicBuffer_v2, CompletionCondition, ReadHandler>& h,
- const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
+ const DefaultCandidate& c = DefaultCandidate()) BOOST_ASIO_NOEXCEPT
{
- return associated_allocator<ReadHandler, Allocator>::get(h.handler_, a);
- }
-};
-
-template <typename AsyncReadStream, typename DynamicBuffer_v2,
- typename CompletionCondition, typename ReadHandler, typename Executor>
-struct associated_executor<
- detail::read_dynbuf_v2_op<AsyncReadStream,
- DynamicBuffer_v2, CompletionCondition, ReadHandler>,
- Executor>
- : detail::associated_executor_forwarding_base<ReadHandler, Executor>
-{
- typedef typename associated_executor<ReadHandler, Executor>::type type;
-
- static type get(
- const detail::read_dynbuf_v2_op<AsyncReadStream,
- DynamicBuffer_v2, CompletionCondition, ReadHandler>& h,
- const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
- {
- return associated_executor<ReadHandler, Executor>::get(h.handler_, ex);
+ return Associator<ReadHandler, DefaultCandidate>::get(h.handler_, c);
}
};
#endif // !defined(GENERATING_DOCUMENTATION)