summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-10-19 20:22:58 (GMT)
committerTobias Markmann <tm@ayena.de>2014-10-20 13:49:33 (GMT)
commit6b22dfcf59474dd016a0355a3102a1dd3692d92c (patch)
tree2b1fd33be433a91e81fee84fdc2bf1b52575d934 /3rdParty/Boost/src/boost/asio/buffered_read_stream.hpp
parent38b0cb785fea8eae5e48fae56440695fdfd10ee1 (diff)
downloadswift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.zip
swift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.tar.bz2
Update Boost in 3rdParty to version 1.56.0.
This updates Boost in our 3rdParty directory to version 1.56.0. Updated our update.sh script to stop on error. Changed error reporting in SwiftTools/CrashReporter.cpp to SWIFT_LOG due to missing include of <iostream> with newer Boost. Change-Id: I4b35c77de951333979a524097f35f5f83d325edc
Diffstat (limited to '3rdParty/Boost/src/boost/asio/buffered_read_stream.hpp')
-rw-r--r--3rdParty/Boost/src/boost/asio/buffered_read_stream.hpp199
1 files changed, 34 insertions, 165 deletions
diff --git a/3rdParty/Boost/src/boost/asio/buffered_read_stream.hpp b/3rdParty/Boost/src/boost/asio/buffered_read_stream.hpp
index 3072580..91493e3 100644
--- a/3rdParty/Boost/src/boost/asio/buffered_read_stream.hpp
+++ b/3rdParty/Boost/src/boost/asio/buffered_read_stream.hpp
@@ -2,7 +2,7 @@
// buffered_read_stream.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2014 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)
@@ -17,13 +17,14 @@
#include <boost/asio/detail/config.hpp>
#include <cstddef>
-#include <boost/type_traits/remove_reference.hpp>
+#include <boost/asio/async_result.hpp>
#include <boost/asio/buffered_read_stream_fwd.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/detail/bind_handler.hpp>
#include <boost/asio/detail/buffer_resize_guard.hpp>
#include <boost/asio/detail/buffered_stream_storage.hpp>
#include <boost/asio/detail/noncopyable.hpp>
+#include <boost/asio/detail/type_traits.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
@@ -42,7 +43,7 @@ namespace asio {
* @e Shared @e objects: Unsafe.
*
* @par Concepts:
- * AsyncReadStream, AsyncWriteStream, Stream, Sync_Read_Stream, SyncWriteStream.
+ * AsyncReadStream, AsyncWriteStream, Stream, SyncReadStream, SyncWriteStream.
*/
template <typename Stream>
class buffered_read_stream
@@ -50,7 +51,7 @@ class buffered_read_stream
{
public:
/// The type of the next layer.
- typedef typename boost::remove_reference<Stream>::type next_layer_type;
+ typedef typename remove_reference<Stream>::type next_layer_type;
/// The type of the lowest layer.
typedef typename next_layer_type::lowest_layer_type lowest_layer_type;
@@ -59,7 +60,7 @@ public:
/// The default buffer size.
static const std::size_t default_buffer_size = implementation_defined;
#else
- BOOST_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024);
+ BOOST_ASIO_STATIC_CONSTANT(std::size_t, default_buffer_size = 1024);
#endif
/// Construct, passing the specified argument to initialise the next layer.
@@ -134,199 +135,65 @@ public:
/// Start an asynchronous write. The data being written must be valid for the
/// lifetime of the asynchronous operation.
template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some(const ConstBufferSequence& buffers,
- WriteHandler handler)
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some(const ConstBufferSequence& buffers,
+ BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
- next_layer_.async_write_some(buffers, handler);
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ next_layer_.async_write_some(buffers,
+ BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t)))(init.handler));
+
+ return init.result.get();
}
/// Fill the buffer with some data. Returns the number of bytes placed in the
/// buffer as a result of the operation. Throws an exception on failure.
- std::size_t fill()
- {
- detail::buffer_resize_guard<detail::buffered_stream_storage>
- resize_guard(storage_);
- std::size_t previous_size = storage_.size();
- storage_.resize(storage_.capacity());
- storage_.resize(previous_size + next_layer_.read_some(buffer(
- storage_.data() + previous_size,
- storage_.size() - previous_size)));
- resize_guard.commit();
- return storage_.size() - previous_size;
- }
+ std::size_t fill();
/// Fill the buffer with some data. Returns the number of bytes placed in the
/// buffer as a result of the operation, or 0 if an error occurred.
- std::size_t fill(boost::system::error_code& ec)
- {
- detail::buffer_resize_guard<detail::buffered_stream_storage>
- resize_guard(storage_);
- std::size_t previous_size = storage_.size();
- storage_.resize(storage_.capacity());
- storage_.resize(previous_size + next_layer_.read_some(buffer(
- storage_.data() + previous_size,
- storage_.size() - previous_size),
- ec));
- resize_guard.commit();
- return storage_.size() - previous_size;
- }
-
- template <typename ReadHandler>
- class fill_handler
- {
- public:
- fill_handler(boost::asio::io_service& io_service,
- detail::buffered_stream_storage& storage,
- std::size_t previous_size, ReadHandler handler)
- : io_service_(io_service),
- storage_(storage),
- previous_size_(previous_size),
- handler_(handler)
- {
- }
-
- void operator()(const boost::system::error_code& ec,
- std::size_t bytes_transferred)
- {
- storage_.resize(previous_size_ + bytes_transferred);
- io_service_.dispatch(detail::bind_handler(
- handler_, ec, bytes_transferred));
- }
-
- private:
- boost::asio::io_service& io_service_;
- detail::buffered_stream_storage& storage_;
- std::size_t previous_size_;
- ReadHandler handler_;
- };
+ std::size_t fill(boost::system::error_code& ec);
/// Start an asynchronous fill.
template <typename ReadHandler>
- void async_fill(ReadHandler handler)
- {
- std::size_t previous_size = storage_.size();
- storage_.resize(storage_.capacity());
- next_layer_.async_read_some(
- buffer(
- storage_.data() + previous_size,
- storage_.size() - previous_size),
- fill_handler<ReadHandler>(get_io_service(),
- storage_, previous_size, handler));
- }
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_fill(BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
/// Read some data from the stream. Returns the number of bytes read. Throws
/// an exception on failure.
template <typename MutableBufferSequence>
- std::size_t read_some(const MutableBufferSequence& buffers)
- {
- if (boost::asio::buffer_size(buffers) == 0)
- return 0;
-
- if (storage_.empty())
- fill();
-
- return copy(buffers);
- }
+ std::size_t read_some(const MutableBufferSequence& buffers);
/// Read some data from the stream. Returns the number of bytes read or 0 if
/// an error occurred.
template <typename MutableBufferSequence>
std::size_t read_some(const MutableBufferSequence& buffers,
- boost::system::error_code& ec)
- {
- ec = boost::system::error_code();
-
- if (boost::asio::buffer_size(buffers) == 0)
- return 0;
-
- if (storage_.empty() && !fill(ec))
- return 0;
-
- return copy(buffers);
- }
-
- template <typename MutableBufferSequence, typename ReadHandler>
- class read_some_handler
- {
- public:
- read_some_handler(boost::asio::io_service& io_service,
- detail::buffered_stream_storage& storage,
- const MutableBufferSequence& buffers, ReadHandler handler)
- : io_service_(io_service),
- storage_(storage),
- buffers_(buffers),
- handler_(handler)
- {
- }
-
- void operator()(const boost::system::error_code& ec, std::size_t)
- {
- if (ec || storage_.empty())
- {
- std::size_t length = 0;
- io_service_.dispatch(detail::bind_handler(handler_, ec, length));
- }
- else
- {
- std::size_t bytes_copied = boost::asio::buffer_copy(
- buffers_, storage_.data(), storage_.size());
- storage_.consume(bytes_copied);
- io_service_.dispatch(detail::bind_handler(handler_, ec, bytes_copied));
- }
- }
-
- private:
- boost::asio::io_service& io_service_;
- detail::buffered_stream_storage& storage_;
- MutableBufferSequence buffers_;
- ReadHandler handler_;
- };
+ boost::system::error_code& ec);
/// Start an asynchronous read. The buffer into which the data will be read
/// must be valid for the lifetime of the asynchronous operation.
template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some(const MutableBufferSequence& buffers,
- ReadHandler handler)
- {
- if (boost::asio::buffer_size(buffers) == 0)
- {
- get_io_service().post(detail::bind_handler(
- handler, boost::system::error_code(), 0));
- }
- else if (storage_.empty())
- {
- async_fill(read_some_handler<MutableBufferSequence, ReadHandler>(
- get_io_service(), storage_, buffers, handler));
- }
- else
- {
- std::size_t length = copy(buffers);
- get_io_service().post(detail::bind_handler(
- handler, boost::system::error_code(), length));
- }
- }
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some(const MutableBufferSequence& buffers,
+ BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
/// Peek at the incoming data on the stream. Returns the number of bytes read.
/// Throws an exception on failure.
template <typename MutableBufferSequence>
- std::size_t peek(const MutableBufferSequence& buffers)
- {
- if (storage_.empty())
- fill();
- return peek_copy(buffers);
- }
+ std::size_t peek(const MutableBufferSequence& buffers);
/// Peek at the incoming data on the stream. Returns the number of bytes read,
/// or 0 if an error occurred.
template <typename MutableBufferSequence>
std::size_t peek(const MutableBufferSequence& buffers,
- boost::system::error_code& ec)
- {
- ec = boost::system::error_code();
- if (storage_.empty() && !fill(ec))
- return 0;
- return peek_copy(buffers);
- }
+ boost::system::error_code& ec);
/// Determine the amount of data that may be read without blocking.
std::size_t in_avail()
@@ -374,4 +241,6 @@ private:
#include <boost/asio/detail/pop_options.hpp>
+#include <boost/asio/impl/buffered_read_stream.hpp>
+
#endif // BOOST_ASIO_BUFFERED_READ_STREAM_HPP