update boost on linux

This commit is contained in:
Bassem Girgis
2019-08-10 16:06:25 -05:00
parent 76ad52be58
commit 861b918727
5363 changed files with 483306 additions and 116507 deletions

View File

@@ -2,7 +2,7 @@
// impl/buffered_write_stream.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -15,10 +15,13 @@
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/detail/handler_alloc_helpers.hpp>
#include <boost/asio/detail/handler_cont_helpers.hpp>
#include <boost/asio/detail/handler_invoke_helpers.hpp>
#include <boost/asio/detail/handler_type_requirements.hpp>
#include <boost/asio/detail/non_const_lvalue.hpp>
#include <boost/asio/detail/push_options.hpp>
@@ -53,7 +56,7 @@ namespace detail
buffered_flush_handler(detail::buffered_stream_storage& storage,
WriteHandler& handler)
: storage_(storage),
handler_(handler)
handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
{
}
@@ -122,7 +125,54 @@ namespace detail
boost_asio_handler_invoke_helpers::invoke(
function, this_handler->handler_);
}
}
struct initiate_async_buffered_flush
{
template <typename WriteHandler, typename Stream>
void operator()(BOOST_ASIO_MOVE_ARG(WriteHandler) handler,
buffered_stream_storage* storage, Stream* next_layer) const
{
// If you get an error on the following line it means that your handler
// does not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
non_const_lvalue<WriteHandler> handler2(handler);
async_write(*next_layer, buffer(storage->data(), storage->size()),
buffered_flush_handler<typename decay<WriteHandler>::type>(
*storage, handler2.value));
}
};
} // namespace detail
#if !defined(GENERATING_DOCUMENTATION)
template <typename WriteHandler, typename Allocator>
struct associated_allocator<
detail::buffered_flush_handler<WriteHandler>, Allocator>
{
typedef typename associated_allocator<WriteHandler, Allocator>::type type;
static type get(const detail::buffered_flush_handler<WriteHandler>& h,
const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
{
return associated_allocator<WriteHandler, Allocator>::get(h.handler_, a);
}
};
template <typename WriteHandler, typename Executor>
struct associated_executor<
detail::buffered_flush_handler<WriteHandler>, Executor>
{
typedef typename associated_executor<WriteHandler, Executor>::type type;
static type get(const detail::buffered_flush_handler<WriteHandler>& h,
const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
{
return associated_executor<WriteHandler, Executor>::get(h.handler_, ex);
}
};
#endif // !defined(GENERATING_DOCUMENTATION)
template <typename Stream>
template <typename WriteHandler>
@@ -131,20 +181,10 @@ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
buffered_write_stream<Stream>::async_flush(
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
detail::async_result_init<
WriteHandler, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
async_write(next_layer_, buffer(storage_.data(), storage_.size()),
detail::buffered_flush_handler<BOOST_ASIO_HANDLER_TYPE(
WriteHandler, void (boost::system::error_code, std::size_t))>(
storage_, init.handler));
return init.result.get();
return async_initiate<WriteHandler,
void (boost::system::error_code, std::size_t)>(
detail::initiate_async_buffered_flush(),
handler, &storage_, &next_layer_);
}
template <typename Stream>
@@ -152,7 +192,8 @@ template <typename ConstBufferSequence>
std::size_t buffered_write_stream<Stream>::write_some(
const ConstBufferSequence& buffers)
{
if (boost::asio::buffer_size(buffers) == 0)
using boost::asio::buffer_size;
if (buffer_size(buffers) == 0)
return 0;
if (storage_.size() == storage_.capacity())
@@ -168,7 +209,8 @@ std::size_t buffered_write_stream<Stream>::write_some(
{
ec = boost::system::error_code();
if (boost::asio::buffer_size(buffers) == 0)
using boost::asio::buffer_size;
if (buffer_size(buffers) == 0)
return 0;
if (storage_.size() == storage_.capacity() && !flush(ec))
@@ -187,7 +229,7 @@ namespace detail
const ConstBufferSequence& buffers, WriteHandler& handler)
: storage_(storage),
buffers_(buffers),
handler_(handler)
handler_(BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))
{
}
@@ -216,9 +258,10 @@ namespace detail
}
else
{
using boost::asio::buffer_size;
std::size_t orig_size = storage_.size();
std::size_t space_avail = storage_.capacity() - orig_size;
std::size_t bytes_avail = boost::asio::buffer_size(buffers_);
std::size_t bytes_avail = buffer_size(buffers_);
std::size_t length = bytes_avail < space_avail
? bytes_avail : space_avail;
storage_.resize(orig_size + length);
@@ -280,8 +323,78 @@ namespace detail
boost_asio_handler_invoke_helpers::invoke(
function, this_handler->handler_);
}
struct initiate_async_buffered_write_some
{
template <typename WriteHandler, typename Stream,
typename ConstBufferSequence>
void operator()(BOOST_ASIO_MOVE_ARG(WriteHandler) handler,
buffered_stream_storage* storage, Stream* next_layer,
const ConstBufferSequence& buffers) const
{
// If you get an error on the following line it means that your handler
// does not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
using boost::asio::buffer_size;
non_const_lvalue<WriteHandler> handler2(handler);
if (buffer_size(buffers) == 0 || storage->size() < storage->capacity())
{
next_layer->async_write_some(BOOST_ASIO_CONST_BUFFER(0, 0),
buffered_write_some_handler<ConstBufferSequence,
typename decay<WriteHandler>::type>(
*storage, buffers, handler2.value));
}
else
{
initiate_async_buffered_flush()(
buffered_write_some_handler<ConstBufferSequence,
typename decay<WriteHandler>::type>(
*storage, buffers, handler2.value),
storage, next_layer);
}
}
};
} // namespace detail
#if !defined(GENERATING_DOCUMENTATION)
template <typename ConstBufferSequence,
typename WriteHandler, typename Allocator>
struct associated_allocator<
detail::buffered_write_some_handler<ConstBufferSequence, WriteHandler>,
Allocator>
{
typedef typename associated_allocator<WriteHandler, Allocator>::type type;
static type get(
const detail::buffered_write_some_handler<
ConstBufferSequence, WriteHandler>& h,
const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
{
return associated_allocator<WriteHandler, Allocator>::get(h.handler_, a);
}
};
template <typename ConstBufferSequence,
typename WriteHandler, typename Executor>
struct associated_executor<
detail::buffered_write_some_handler<ConstBufferSequence, WriteHandler>,
Executor>
{
typedef typename associated_executor<WriteHandler, Executor>::type type;
static type get(
const detail::buffered_write_some_handler<
ConstBufferSequence, WriteHandler>& h,
const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
{
return associated_executor<WriteHandler, Executor>::get(h.handler_, ex);
}
};
#endif // !defined(GENERATING_DOCUMENTATION)
template <typename Stream>
template <typename ConstBufferSequence, typename WriteHandler>
BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
@@ -290,32 +403,10 @@ buffered_write_stream<Stream>::async_write_some(
const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
detail::async_result_init<
WriteHandler, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
if (boost::asio::buffer_size(buffers) == 0
|| storage_.size() < storage_.capacity())
{
next_layer_.async_write_some(boost::asio::const_buffers_1(0, 0),
detail::buffered_write_some_handler<
ConstBufferSequence, BOOST_ASIO_HANDLER_TYPE(
WriteHandler, void (boost::system::error_code, std::size_t))>(
storage_, buffers, init.handler));
}
else
{
this->async_flush(detail::buffered_write_some_handler<
ConstBufferSequence, BOOST_ASIO_HANDLER_TYPE(
WriteHandler, void (boost::system::error_code, std::size_t))>(
storage_, buffers, init.handler));
}
return init.result.get();
return async_initiate<WriteHandler,
void (boost::system::error_code, std::size_t)>(
detail::initiate_async_buffered_write_some(),
handler, &storage_, &next_layer_, buffers);
}
template <typename Stream>
@@ -323,9 +414,10 @@ template <typename ConstBufferSequence>
std::size_t buffered_write_stream<Stream>::copy(
const ConstBufferSequence& buffers)
{
using boost::asio::buffer_size;
std::size_t orig_size = storage_.size();
std::size_t space_avail = storage_.capacity() - orig_size;
std::size_t bytes_avail = boost::asio::buffer_size(buffers);
std::size_t bytes_avail = buffer_size(buffers);
std::size_t length = bytes_avail < space_avail ? bytes_avail : space_avail;
storage_.resize(orig_size + length);
return boost::asio::buffer_copy(