Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 25E0018DA4 for ; Thu, 29 Oct 2015 17:57:05 +0000 (UTC) Received: (qmail 69204 invoked by uid 500); 29 Oct 2015 17:56:50 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 68953 invoked by uid 500); 29 Oct 2015 17:56:50 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 66919 invoked by uid 99); 29 Oct 2015 17:56:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Oct 2015 17:56:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6F8F9E393F; Thu, 29 Oct 2015 17:56:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: wheat9@apache.org To: common-commits@hadoop.apache.org Date: Thu, 29 Oct 2015 17:57:11 -0000 Message-Id: In-Reply-To: <69cea49564874dab90680a0d4f02f069@git.apache.org> References: <69cea49564874dab90680a0d4f02f069@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [25/54] [abbrv] [partial] hadoop git commit: HDFS-9207. Move the implementation to the hdfs-native-client module. Contributed by Haohui Mai. http://git-wip-us.apache.org/repos/asf/hadoop/blob/76a1e894/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/buffered_write_stream.hpp ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/buffered_write_stream.hpp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/buffered_write_stream.hpp deleted file mode 100644 index 1e51c11..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/buffered_write_stream.hpp +++ /dev/null @@ -1,338 +0,0 @@ -// -// impl/buffered_write_stream.hpp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// 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) -// - -#ifndef ASIO_IMPL_BUFFERED_WRITE_STREAM_HPP -#define ASIO_IMPL_BUFFERED_WRITE_STREAM_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/handler_alloc_helpers.hpp" -#include "asio/detail/handler_cont_helpers.hpp" -#include "asio/detail/handler_invoke_helpers.hpp" -#include "asio/detail/handler_type_requirements.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { - -template -std::size_t buffered_write_stream::flush() -{ - std::size_t bytes_written = write(next_layer_, - buffer(storage_.data(), storage_.size())); - storage_.consume(bytes_written); - return bytes_written; -} - -template -std::size_t buffered_write_stream::flush(asio::error_code& ec) -{ - std::size_t bytes_written = write(next_layer_, - buffer(storage_.data(), storage_.size()), - transfer_all(), ec); - storage_.consume(bytes_written); - return bytes_written; -} - -namespace detail -{ - template - class buffered_flush_handler - { - public: - buffered_flush_handler(detail::buffered_stream_storage& storage, - WriteHandler& handler) - : storage_(storage), - handler_(handler) - { - } - -#if defined(ASIO_HAS_MOVE) - buffered_flush_handler(const buffered_flush_handler& other) - : storage_(other.storage_), - handler_(other.handler_) - { - } - - buffered_flush_handler(buffered_flush_handler&& other) - : storage_(other.storage_), - handler_(ASIO_MOVE_CAST(WriteHandler)(other.handler_)) - { - } -#endif // defined(ASIO_HAS_MOVE) - - void operator()(const asio::error_code& ec, - const std::size_t bytes_written) - { - storage_.consume(bytes_written); - handler_(ec, bytes_written); - } - - //private: - detail::buffered_stream_storage& storage_; - WriteHandler handler_; - }; - - template - inline void* asio_handler_allocate(std::size_t size, - buffered_flush_handler* this_handler) - { - return asio_handler_alloc_helpers::allocate( - size, this_handler->handler_); - } - - template - inline void asio_handler_deallocate(void* pointer, std::size_t size, - buffered_flush_handler* this_handler) - { - asio_handler_alloc_helpers::deallocate( - pointer, size, this_handler->handler_); - } - - template - inline bool asio_handler_is_continuation( - buffered_flush_handler* this_handler) - { - return asio_handler_cont_helpers::is_continuation( - this_handler->handler_); - } - - template - inline void asio_handler_invoke(Function& function, - buffered_flush_handler* this_handler) - { - asio_handler_invoke_helpers::invoke( - function, this_handler->handler_); - } - - template - inline void asio_handler_invoke(const Function& function, - buffered_flush_handler* this_handler) - { - asio_handler_invoke_helpers::invoke( - function, this_handler->handler_); - } -} - -template -template -ASIO_INITFN_RESULT_TYPE(WriteHandler, - void (asio::error_code, std::size_t)) -buffered_write_stream::async_flush( - 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. - ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; - - detail::async_result_init< - WriteHandler, void (asio::error_code, std::size_t)> init( - ASIO_MOVE_CAST(WriteHandler)(handler)); - - async_write(next_layer_, buffer(storage_.data(), storage_.size()), - detail::buffered_flush_handler( - storage_, init.handler)); - - return init.result.get(); -} - -template -template -std::size_t buffered_write_stream::write_some( - const ConstBufferSequence& buffers) -{ - if (asio::buffer_size(buffers) == 0) - return 0; - - if (storage_.size() == storage_.capacity()) - this->flush(); - - return this->copy(buffers); -} - -template -template -std::size_t buffered_write_stream::write_some( - const ConstBufferSequence& buffers, asio::error_code& ec) -{ - ec = asio::error_code(); - - if (asio::buffer_size(buffers) == 0) - return 0; - - if (storage_.size() == storage_.capacity() && !flush(ec)) - return 0; - - return this->copy(buffers); -} - -namespace detail -{ - template - class buffered_write_some_handler - { - public: - buffered_write_some_handler(detail::buffered_stream_storage& storage, - const ConstBufferSequence& buffers, WriteHandler& handler) - : storage_(storage), - buffers_(buffers), - handler_(handler) - { - } - -#if defined(ASIO_HAS_MOVE) - buffered_write_some_handler(const buffered_write_some_handler& other) - : storage_(other.storage_), - buffers_(other.buffers_), - handler_(other.handler_) - { - } - - buffered_write_some_handler(buffered_write_some_handler&& other) - : storage_(other.storage_), - buffers_(other.buffers_), - handler_(ASIO_MOVE_CAST(WriteHandler)(other.handler_)) - { - } -#endif // defined(ASIO_HAS_MOVE) - - void operator()(const asio::error_code& ec, std::size_t) - { - if (ec) - { - const std::size_t length = 0; - handler_(ec, length); - } - else - { - std::size_t orig_size = storage_.size(); - std::size_t space_avail = storage_.capacity() - orig_size; - std::size_t bytes_avail = asio::buffer_size(buffers_); - std::size_t length = bytes_avail < space_avail - ? bytes_avail : space_avail; - storage_.resize(orig_size + length); - const std::size_t bytes_copied = asio::buffer_copy( - storage_.data() + orig_size, buffers_, length); - handler_(ec, bytes_copied); - } - } - - //private: - detail::buffered_stream_storage& storage_; - ConstBufferSequence buffers_; - WriteHandler handler_; - }; - - template - inline void* asio_handler_allocate(std::size_t size, - buffered_write_some_handler< - ConstBufferSequence, WriteHandler>* this_handler) - { - return asio_handler_alloc_helpers::allocate( - size, this_handler->handler_); - } - - template - inline void asio_handler_deallocate(void* pointer, std::size_t size, - buffered_write_some_handler< - ConstBufferSequence, WriteHandler>* this_handler) - { - asio_handler_alloc_helpers::deallocate( - pointer, size, this_handler->handler_); - } - - template - inline bool asio_handler_is_continuation( - buffered_write_some_handler< - ConstBufferSequence, WriteHandler>* this_handler) - { - return asio_handler_cont_helpers::is_continuation( - this_handler->handler_); - } - - template - inline void asio_handler_invoke(Function& function, - buffered_write_some_handler< - ConstBufferSequence, WriteHandler>* this_handler) - { - asio_handler_invoke_helpers::invoke( - function, this_handler->handler_); - } - - template - inline void asio_handler_invoke(const Function& function, - buffered_write_some_handler< - ConstBufferSequence, WriteHandler>* this_handler) - { - asio_handler_invoke_helpers::invoke( - function, this_handler->handler_); - } -} // namespace detail - -template -template -ASIO_INITFN_RESULT_TYPE(WriteHandler, - void (asio::error_code, std::size_t)) -buffered_write_stream::async_write_some( - const ConstBufferSequence& buffers, - 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. - ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check; - - detail::async_result_init< - WriteHandler, void (asio::error_code, std::size_t)> init( - ASIO_MOVE_CAST(WriteHandler)(handler)); - - if (asio::buffer_size(buffers) == 0 - || storage_.size() < storage_.capacity()) - { - next_layer_.async_write_some(asio::const_buffers_1(0, 0), - detail::buffered_write_some_handler< - ConstBufferSequence, ASIO_HANDLER_TYPE( - WriteHandler, void (asio::error_code, std::size_t))>( - storage_, buffers, init.handler)); - } - else - { - this->async_flush(detail::buffered_write_some_handler< - ConstBufferSequence, ASIO_HANDLER_TYPE( - WriteHandler, void (asio::error_code, std::size_t))>( - storage_, buffers, init.handler)); - } - - return init.result.get(); -} - -template -template -std::size_t buffered_write_stream::copy( - const ConstBufferSequence& buffers) -{ - std::size_t orig_size = storage_.size(); - std::size_t space_avail = storage_.capacity() - orig_size; - std::size_t bytes_avail = asio::buffer_size(buffers); - std::size_t length = bytes_avail < space_avail ? bytes_avail : space_avail; - storage_.resize(orig_size + length); - return asio::buffer_copy( - storage_.data() + orig_size, buffers, length); -} - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_IMPL_BUFFERED_WRITE_STREAM_HPP http://git-wip-us.apache.org/repos/asf/hadoop/blob/76a1e894/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/connect.hpp ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/connect.hpp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/connect.hpp deleted file mode 100644 index 523e551..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/connect.hpp +++ /dev/null @@ -1,428 +0,0 @@ -// -// impl/connect.hpp -// ~~~~~~~~~~~~~~~~ -// -// 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) -// - -#ifndef ASIO_IMPL_CONNECT_HPP -#define ASIO_IMPL_CONNECT_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/bind_handler.hpp" -#include "asio/detail/consuming_buffers.hpp" -#include "asio/detail/handler_alloc_helpers.hpp" -#include "asio/detail/handler_cont_helpers.hpp" -#include "asio/detail/handler_invoke_helpers.hpp" -#include "asio/detail/handler_type_requirements.hpp" -#include "asio/detail/throw_error.hpp" -#include "asio/error.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { - -namespace detail -{ - struct default_connect_condition - { - template - Iterator operator()(const asio::error_code&, Iterator next) - { - return next; - } - }; -} - -template -Iterator connect(basic_socket& s, Iterator begin) -{ - asio::error_code ec; - Iterator result = connect(s, begin, ec); - asio::detail::throw_error(ec, "connect"); - return result; -} - -template -inline Iterator connect(basic_socket& s, - Iterator begin, asio::error_code& ec) -{ - return connect(s, begin, Iterator(), detail::default_connect_condition(), ec); -} - -template -Iterator connect(basic_socket& s, - Iterator begin, Iterator end) -{ - asio::error_code ec; - Iterator result = connect(s, begin, end, ec); - asio::detail::throw_error(ec, "connect"); - return result; -} - -template -inline Iterator connect(basic_socket& s, - Iterator begin, Iterator end, asio::error_code& ec) -{ - return connect(s, begin, end, detail::default_connect_condition(), ec); -} - -template -Iterator connect(basic_socket& s, - Iterator begin, ConnectCondition connect_condition) -{ - asio::error_code ec; - Iterator result = connect(s, begin, connect_condition, ec); - asio::detail::throw_error(ec, "connect"); - return result; -} - -template -inline Iterator connect(basic_socket& s, - Iterator begin, ConnectCondition connect_condition, - asio::error_code& ec) -{ - return connect(s, begin, Iterator(), connect_condition, ec); -} - -template -Iterator connect(basic_socket& s, - Iterator begin, Iterator end, ConnectCondition connect_condition) -{ - asio::error_code ec; - Iterator result = connect(s, begin, end, connect_condition, ec); - asio::detail::throw_error(ec, "connect"); - return result; -} - -template -Iterator connect(basic_socket& s, - Iterator begin, Iterator end, ConnectCondition connect_condition, - asio::error_code& ec) -{ - ec = asio::error_code(); - - for (Iterator iter = begin; iter != end; ++iter) - { - iter = connect_condition(ec, iter); - if (iter != end) - { - s.close(ec); - s.connect(*iter, ec); - if (!ec) - return iter; - } - } - - if (!ec) - ec = asio::error::not_found; - - return end; -} - -namespace detail -{ - // Enable the empty base class optimisation for the connect condition. - template - class base_from_connect_condition - { - protected: - explicit base_from_connect_condition( - const ConnectCondition& connect_condition) - : connect_condition_(connect_condition) - { - } - - template - void check_condition(const asio::error_code& ec, - Iterator& iter, Iterator& end) - { - if (iter != end) - iter = connect_condition_(ec, static_cast(iter)); - } - - private: - ConnectCondition connect_condition_; - }; - - // The default_connect_condition implementation is essentially a no-op. This - // template specialisation lets us eliminate all costs associated with it. - template <> - class base_from_connect_condition - { - protected: - explicit base_from_connect_condition(const default_connect_condition&) - { - } - - template - void check_condition(const asio::error_code&, Iterator&, Iterator&) - { - } - }; - - template - class connect_op : base_from_connect_condition - { - public: - connect_op(basic_socket& sock, - const Iterator& begin, const Iterator& end, - const ConnectCondition& connect_condition, - ComposedConnectHandler& handler) - : base_from_connect_condition(connect_condition), - socket_(sock), - iter_(begin), - end_(end), - start_(0), - handler_(ASIO_MOVE_CAST(ComposedConnectHandler)(handler)) - { - } - -#if defined(ASIO_HAS_MOVE) - connect_op(const connect_op& other) - : base_from_connect_condition(other), - socket_(other.socket_), - iter_(other.iter_), - end_(other.end_), - start_(other.start_), - handler_(other.handler_) - { - } - - connect_op(connect_op&& other) - : base_from_connect_condition(other), - socket_(other.socket_), - iter_(other.iter_), - end_(other.end_), - start_(other.start_), - handler_(ASIO_MOVE_CAST(ComposedConnectHandler)(other.handler_)) - { - } -#endif // defined(ASIO_HAS_MOVE) - - void operator()(asio::error_code ec, int start = 0) - { - switch (start_ = start) - { - case 1: - for (;;) - { - this->check_condition(ec, iter_, end_); - - if (iter_ != end_) - { - socket_.close(ec); - socket_.async_connect(*iter_, - ASIO_MOVE_CAST(connect_op)(*this)); - return; - } - - if (start) - { - ec = asio::error::not_found; - socket_.get_io_service().post(detail::bind_handler(*this, ec)); - return; - } - - default: - - if (iter_ == end_) - break; - - if (!socket_.is_open()) - { - ec = asio::error::operation_aborted; - break; - } - - if (!ec) - break; - - ++iter_; - } - - handler_(static_cast(ec), - static_cast(iter_)); - } - } - - //private: - basic_socket& socket_; - Iterator iter_; - Iterator end_; - int start_; - ComposedConnectHandler handler_; - }; - - template - inline void* asio_handler_allocate(std::size_t size, - connect_op* this_handler) - { - return asio_handler_alloc_helpers::allocate( - size, this_handler->handler_); - } - - template - inline void asio_handler_deallocate(void* pointer, std::size_t size, - connect_op* this_handler) - { - asio_handler_alloc_helpers::deallocate( - pointer, size, this_handler->handler_); - } - - template - inline bool asio_handler_is_continuation( - connect_op* this_handler) - { - return asio_handler_cont_helpers::is_continuation( - this_handler->handler_); - } - - template - inline void asio_handler_invoke(Function& function, - connect_op* this_handler) - { - asio_handler_invoke_helpers::invoke( - function, this_handler->handler_); - } - - template - inline void asio_handler_invoke(const Function& function, - connect_op* this_handler) - { - asio_handler_invoke_helpers::invoke( - function, this_handler->handler_); - } -} // namespace detail - -template -inline ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, - void (asio::error_code, Iterator)) -async_connect(basic_socket& s, - Iterator begin, ASIO_MOVE_ARG(ComposedConnectHandler) handler) -{ - // If you get an error on the following line it means that your handler does - // not meet the documented type requirements for a ComposedConnectHandler. - ASIO_COMPOSED_CONNECT_HANDLER_CHECK( - ComposedConnectHandler, handler, Iterator) type_check; - - detail::async_result_init init( - ASIO_MOVE_CAST(ComposedConnectHandler)(handler)); - - detail::connect_op(s, - begin, Iterator(), detail::default_connect_condition(), init.handler)( - asio::error_code(), 1); - - return init.result.get(); -} - -template -inline ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, - void (asio::error_code, Iterator)) -async_connect(basic_socket& s, - Iterator begin, Iterator end, - ASIO_MOVE_ARG(ComposedConnectHandler) handler) -{ - // If you get an error on the following line it means that your handler does - // not meet the documented type requirements for a ComposedConnectHandler. - ASIO_COMPOSED_CONNECT_HANDLER_CHECK( - ComposedConnectHandler, handler, Iterator) type_check; - - detail::async_result_init init( - ASIO_MOVE_CAST(ComposedConnectHandler)(handler)); - - detail::connect_op(s, - begin, end, detail::default_connect_condition(), init.handler)( - asio::error_code(), 1); - - return init.result.get(); -} - -template -inline ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, - void (asio::error_code, Iterator)) -async_connect(basic_socket& s, - Iterator begin, ConnectCondition connect_condition, - ASIO_MOVE_ARG(ComposedConnectHandler) handler) -{ - // If you get an error on the following line it means that your handler does - // not meet the documented type requirements for a ComposedConnectHandler. - ASIO_COMPOSED_CONNECT_HANDLER_CHECK( - ComposedConnectHandler, handler, Iterator) type_check; - - detail::async_result_init init( - ASIO_MOVE_CAST(ComposedConnectHandler)(handler)); - - detail::connect_op(s, - begin, Iterator(), connect_condition, init.handler)( - asio::error_code(), 1); - - return init.result.get(); -} - -template -inline ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler, - void (asio::error_code, Iterator)) -async_connect(basic_socket& s, - Iterator begin, Iterator end, ConnectCondition connect_condition, - ASIO_MOVE_ARG(ComposedConnectHandler) handler) -{ - // If you get an error on the following line it means that your handler does - // not meet the documented type requirements for a ComposedConnectHandler. - ASIO_COMPOSED_CONNECT_HANDLER_CHECK( - ComposedConnectHandler, handler, Iterator) type_check; - - detail::async_result_init init( - ASIO_MOVE_CAST(ComposedConnectHandler)(handler)); - - detail::connect_op(s, - begin, end, connect_condition, init.handler)( - asio::error_code(), 1); - - return init.result.get(); -} - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_IMPL_CONNECT_HPP http://git-wip-us.apache.org/repos/asf/hadoop/blob/76a1e894/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/error.ipp ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/error.ipp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/error.ipp deleted file mode 100644 index 7c5a414..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/error.ipp +++ /dev/null @@ -1,128 +0,0 @@ -// -// impl/error.ipp -// ~~~~~~~~~~~~~~ -// -// 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) -// - -#ifndef ASIO_IMPL_ERROR_IPP -#define ASIO_IMPL_ERROR_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/config.hpp" -#include -#include "asio/error.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { -namespace error { - -#if !defined(ASIO_WINDOWS) && !defined(__CYGWIN__) - -namespace detail { - -class netdb_category : public asio::error_category -{ -public: - const char* name() const ASIO_ERROR_CATEGORY_NOEXCEPT - { - return "asio.netdb"; - } - - std::string message(int value) const - { - if (value == error::host_not_found) - return "Host not found (authoritative)"; - if (value == error::host_not_found_try_again) - return "Host not found (non-authoritative), try again later"; - if (value == error::no_data) - return "The query is valid, but it does not have associated data"; - if (value == error::no_recovery) - return "A non-recoverable error occurred during database lookup"; - return "asio.netdb error"; - } -}; - -} // namespace detail - -const asio::error_category& get_netdb_category() -{ - static detail::netdb_category instance; - return instance; -} - -namespace detail { - -class addrinfo_category : public asio::error_category -{ -public: - const char* name() const ASIO_ERROR_CATEGORY_NOEXCEPT - { - return "asio.addrinfo"; - } - - std::string message(int value) const - { - if (value == error::service_not_found) - return "Service not found"; - if (value == error::socket_type_not_supported) - return "Socket type not supported"; - return "asio.addrinfo error"; - } -}; - -} // namespace detail - -const asio::error_category& get_addrinfo_category() -{ - static detail::addrinfo_category instance; - return instance; -} - -#endif // !defined(ASIO_WINDOWS) && !defined(__CYGWIN__) - -namespace detail { - -class misc_category : public asio::error_category -{ -public: - const char* name() const ASIO_ERROR_CATEGORY_NOEXCEPT - { - return "asio.misc"; - } - - std::string message(int value) const - { - if (value == error::already_open) - return "Already open"; - if (value == error::eof) - return "End of file"; - if (value == error::not_found) - return "Element not found"; - if (value == error::fd_set_failure) - return "The descriptor does not fit into the select call's fd_set"; - return "asio.misc error"; - } -}; - -} // namespace detail - -const asio::error_category& get_misc_category() -{ - static detail::misc_category instance; - return instance; -} - -} // namespace error -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_IMPL_ERROR_IPP http://git-wip-us.apache.org/repos/asf/hadoop/blob/76a1e894/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/error_code.ipp ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/error_code.ipp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/error_code.ipp deleted file mode 100644 index ec0536e..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/error_code.ipp +++ /dev/null @@ -1,128 +0,0 @@ -// -// impl/error_code.ipp -// ~~~~~~~~~~~~~~~~~~~ -// -// 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) -// - -#ifndef ASIO_IMPL_ERROR_CODE_IPP -#define ASIO_IMPL_ERROR_CODE_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/config.hpp" -#if defined(ASIO_WINDOWS) || defined(__CYGWIN__) -# include -#elif defined(ASIO_WINDOWS_RUNTIME) -# include -#else -# include -# include -# include -#endif -#include "asio/detail/local_free_on_block_exit.hpp" -#include "asio/detail/socket_types.hpp" -#include "asio/error_code.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { -namespace detail { - -class system_category : public error_category -{ -public: - const char* name() const ASIO_ERROR_CATEGORY_NOEXCEPT - { - return "asio.system"; - } - - std::string message(int value) const - { -#if defined(ASIO_WINDOWS) || defined(__CYGWIN__) - char* msg = 0; - DWORD length = ::FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER - | FORMAT_MESSAGE_FROM_SYSTEM - | FORMAT_MESSAGE_IGNORE_INSERTS, 0, value, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char*)&msg, 0, 0); - detail::local_free_on_block_exit local_free_obj(msg); - if (length && msg[length - 1] == '\n') - msg[--length] = '\0'; - if (length && msg[length - 1] == '\r') - msg[--length] = '\0'; - if (length) - return msg; - else - return "asio.system error"; -#elif defined(ASIO_WINDOWS_RUNTIME) - std::wstring wmsg(128, wchar_t()); - for (;;) - { - DWORD wlength = ::FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM - | FORMAT_MESSAGE_IGNORE_INSERTS, 0, value, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &wmsg[0], wmsg.size(), 0); - if (wlength == 0 && ::GetLastError() == ERROR_INSUFFICIENT_BUFFER) - { - wmsg.resize(wmsg.size() + wmsg.size() / 2); - continue; - } - if (wlength && wmsg[wlength - 1] == '\n') - --wlength; - if (wlength && wmsg[wlength - 1] == '\r') - --wlength; - if (wlength) - { - std::string msg(wlength * 2, char()); - int length = ::WideCharToMultiByte(CP_ACP, 0, - wmsg.c_str(), static_cast(wlength), - &msg[0], static_cast(wlength * 2), 0, 0); - if (length <= 0) - return "asio.system error"; - msg.resize(static_cast(length)); - return msg; - } - else - return "asio.system error"; - } -#else // defined(ASIO_WINDOWS) -#if !defined(__sun) - if (value == ECANCELED) - return "Operation aborted."; -#endif // !defined(__sun) -#if defined(__sun) || defined(__QNX__) || defined(__SYMBIAN32__) - using namespace std; - return strerror(value); -#elif defined(__MACH__) && defined(__APPLE__) \ - || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) \ - || defined(_AIX) || defined(__hpux) || defined(__osf__) \ - || defined(__ANDROID__) - char buf[256] = ""; - using namespace std; - strerror_r(value, buf, sizeof(buf)); - return buf; -#else - char buf[256] = ""; - return strerror_r(value, buf, sizeof(buf)); -#endif -#endif // defined(ASIO_WINDOWS) - } -}; - -} // namespace detail - -const error_category& system_category() -{ - static detail::system_category instance; - return instance; -} - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_IMPL_ERROR_CODE_IPP http://git-wip-us.apache.org/repos/asf/hadoop/blob/76a1e894/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/handler_alloc_hook.ipp ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/handler_alloc_hook.ipp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/handler_alloc_hook.ipp deleted file mode 100644 index 8691ef5..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/handler_alloc_hook.ipp +++ /dev/null @@ -1,77 +0,0 @@ -// -// impl/handler_alloc_hook.ipp -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// 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) -// - -#ifndef ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP -#define ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/config.hpp" -#include "asio/detail/call_stack.hpp" -#include "asio/handler_alloc_hook.hpp" - -#if !defined(ASIO_DISABLE_SMALL_BLOCK_RECYCLING) -# if defined(ASIO_HAS_IOCP) -# include "asio/detail/win_iocp_thread_info.hpp" -# else // defined(ASIO_HAS_IOCP) -# include "asio/detail/task_io_service_thread_info.hpp" -# endif // defined(ASIO_HAS_IOCP) -#endif // !defined(ASIO_DISABLE_SMALL_BLOCK_RECYCLING) - -#include "asio/detail/push_options.hpp" - -namespace asio { - -#if defined(ASIO_HAS_IOCP) -namespace detail { class win_iocp_io_service; } -#endif // defined(ASIO_HAS_IOCP) - -void* asio_handler_allocate(std::size_t size, ...) -{ -#if !defined(ASIO_DISABLE_SMALL_BLOCK_RECYCLING) -# if defined(ASIO_HAS_IOCP) - typedef detail::win_iocp_io_service io_service_impl; - typedef detail::win_iocp_thread_info thread_info; -# else // defined(ASIO_HAS_IOCP) - typedef detail::task_io_service io_service_impl; - typedef detail::task_io_service_thread_info thread_info; -# endif // defined(ASIO_HAS_IOCP) - typedef detail::call_stack call_stack; - return thread_info::allocate(call_stack::top(), size); -#else // !defined(ASIO_DISABLE_SMALL_BLOCK_RECYCLING) - return ::operator new(size); -#endif // !defined(ASIO_DISABLE_SMALL_BLOCK_RECYCLING) -} - -void asio_handler_deallocate(void* pointer, std::size_t size, ...) -{ -#if !defined(ASIO_DISABLE_SMALL_BLOCK_RECYCLING) -# if defined(ASIO_HAS_IOCP) - typedef detail::win_iocp_io_service io_service_impl; - typedef detail::win_iocp_thread_info thread_info; -# else // defined(ASIO_HAS_IOCP) - typedef detail::task_io_service io_service_impl; - typedef detail::task_io_service_thread_info thread_info; -# endif // defined(ASIO_HAS_IOCP) - typedef detail::call_stack call_stack; - thread_info::deallocate(call_stack::top(), pointer, size); -#else // !defined(ASIO_DISABLE_SMALL_BLOCK_RECYCLING) - (void)size; - ::operator delete(pointer); -#endif // !defined(ASIO_DISABLE_SMALL_BLOCK_RECYCLING) -} - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_IMPL_HANDLER_ALLOC_HOOK_IPP http://git-wip-us.apache.org/repos/asf/hadoop/blob/76a1e894/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/io_service.hpp ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/io_service.hpp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/io_service.hpp deleted file mode 100644 index 6e590ac..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/io_service.hpp +++ /dev/null @@ -1,152 +0,0 @@ -// -// impl/io_service.hpp -// ~~~~~~~~~~~~~~~~~~~ -// -// 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) -// - -#ifndef ASIO_IMPL_IO_SERVICE_HPP -#define ASIO_IMPL_IO_SERVICE_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/handler_type_requirements.hpp" -#include "asio/detail/service_registry.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { - -template -inline Service& use_service(io_service& ios) -{ - // Check that Service meets the necessary type requirements. - (void)static_cast(static_cast(0)); - (void)static_cast(&Service::id); - - return ios.service_registry_->template use_service(); -} - -template <> -inline detail::io_service_impl& use_service( - io_service& ios) -{ - return ios.impl_; -} - -template -inline void add_service(io_service& ios, Service* svc) -{ - // Check that Service meets the necessary type requirements. - (void)static_cast(static_cast(0)); - (void)static_cast(&Service::id); - - ios.service_registry_->template add_service(svc); -} - -template -inline bool has_service(io_service& ios) -{ - // Check that Service meets the necessary type requirements. - (void)static_cast(static_cast(0)); - (void)static_cast(&Service::id); - - return ios.service_registry_->template has_service(); -} - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#if defined(ASIO_HAS_IOCP) -# include "asio/detail/win_iocp_io_service.hpp" -#else -# include "asio/detail/task_io_service.hpp" -#endif - -#include "asio/detail/push_options.hpp" - -namespace asio { - -template -inline ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ()) -io_service::dispatch(ASIO_MOVE_ARG(CompletionHandler) handler) -{ - // If you get an error on the following line it means that your handler does - // not meet the documented type requirements for a CompletionHandler. - ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check; - - detail::async_result_init< - CompletionHandler, void ()> init( - ASIO_MOVE_CAST(CompletionHandler)(handler)); - - impl_.dispatch(init.handler); - - return init.result.get(); -} - -template -inline ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ()) -io_service::post(ASIO_MOVE_ARG(CompletionHandler) handler) -{ - // If you get an error on the following line it means that your handler does - // not meet the documented type requirements for a CompletionHandler. - ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check; - - detail::async_result_init< - CompletionHandler, void ()> init( - ASIO_MOVE_CAST(CompletionHandler)(handler)); - - impl_.post(init.handler); - - return init.result.get(); -} - -template -#if defined(GENERATING_DOCUMENTATION) -unspecified -#else -inline detail::wrapped_handler -#endif -io_service::wrap(Handler handler) -{ - return detail::wrapped_handler(*this, handler); -} - -inline io_service::work::work(asio::io_service& io_service) - : io_service_impl_(io_service.impl_) -{ - io_service_impl_.work_started(); -} - -inline io_service::work::work(const work& other) - : io_service_impl_(other.io_service_impl_) -{ - io_service_impl_.work_started(); -} - -inline io_service::work::~work() -{ - io_service_impl_.work_finished(); -} - -inline asio::io_service& io_service::work::get_io_service() -{ - return io_service_impl_.get_io_service(); -} - -inline asio::io_service& io_service::service::get_io_service() -{ - return owner_; -} - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_IMPL_IO_SERVICE_HPP http://git-wip-us.apache.org/repos/asf/hadoop/blob/76a1e894/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/io_service.ipp ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/io_service.ipp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/io_service.ipp deleted file mode 100644 index 4844ef3..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/io_service.ipp +++ /dev/null @@ -1,155 +0,0 @@ -// -// impl/io_service.ipp -// ~~~~~~~~~~~~~~~~~~~ -// -// 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) -// - -#ifndef ASIO_IMPL_IO_SERVICE_IPP -#define ASIO_IMPL_IO_SERVICE_IPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/config.hpp" -#include "asio/io_service.hpp" -#include "asio/detail/limits.hpp" -#include "asio/detail/scoped_ptr.hpp" -#include "asio/detail/service_registry.hpp" -#include "asio/detail/throw_error.hpp" - -#if defined(ASIO_HAS_IOCP) -# include "asio/detail/win_iocp_io_service.hpp" -#else -# include "asio/detail/task_io_service.hpp" -#endif - -#include "asio/detail/push_options.hpp" - -namespace asio { - -io_service::io_service() - : service_registry_(new asio::detail::service_registry( - *this, static_cast(0), - (std::numeric_limits::max)())), - impl_(service_registry_->first_service()) -{ -} - -io_service::io_service(std::size_t concurrency_hint) - : service_registry_(new asio::detail::service_registry( - *this, static_cast(0), concurrency_hint)), - impl_(service_registry_->first_service()) -{ -} - -io_service::~io_service() -{ - delete service_registry_; -} - -std::size_t io_service::run() -{ - asio::error_code ec; - std::size_t s = impl_.run(ec); - asio::detail::throw_error(ec); - return s; -} - -std::size_t io_service::run(asio::error_code& ec) -{ - return impl_.run(ec); -} - -std::size_t io_service::run_one() -{ - asio::error_code ec; - std::size_t s = impl_.run_one(ec); - asio::detail::throw_error(ec); - return s; -} - -std::size_t io_service::run_one(asio::error_code& ec) -{ - return impl_.run_one(ec); -} - -std::size_t io_service::poll() -{ - asio::error_code ec; - std::size_t s = impl_.poll(ec); - asio::detail::throw_error(ec); - return s; -} - -std::size_t io_service::poll(asio::error_code& ec) -{ - return impl_.poll(ec); -} - -std::size_t io_service::poll_one() -{ - asio::error_code ec; - std::size_t s = impl_.poll_one(ec); - asio::detail::throw_error(ec); - return s; -} - -std::size_t io_service::poll_one(asio::error_code& ec) -{ - return impl_.poll_one(ec); -} - -void io_service::stop() -{ - impl_.stop(); -} - -bool io_service::stopped() const -{ - return impl_.stopped(); -} - -void io_service::reset() -{ - impl_.reset(); -} - -void io_service::notify_fork(asio::io_service::fork_event event) -{ - service_registry_->notify_fork(event); -} - -io_service::service::service(asio::io_service& owner) - : owner_(owner), - next_(0) -{ -} - -io_service::service::~service() -{ -} - -void io_service::service::fork_service(asio::io_service::fork_event) -{ -} - -service_already_exists::service_already_exists() - : std::logic_error("Service already exists.") -{ -} - -invalid_service_owner::invalid_service_owner() - : std::logic_error("Invalid service owner.") -{ -} - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_IMPL_IO_SERVICE_IPP http://git-wip-us.apache.org/repos/asf/hadoop/blob/76a1e894/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read.hpp ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read.hpp b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read.hpp deleted file mode 100644 index 63fba77..0000000 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/native/libhdfspp/third_party/asio-1.10.2/include/asio/impl/read.hpp +++ /dev/null @@ -1,753 +0,0 @@ -// -// impl/read.hpp -// ~~~~~~~~~~~~~ -// -// 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) -// - -#ifndef ASIO_IMPL_READ_HPP -#define ASIO_IMPL_READ_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include -#include "asio/buffer.hpp" -#include "asio/completion_condition.hpp" -#include "asio/detail/array_fwd.hpp" -#include "asio/detail/base_from_completion_cond.hpp" -#include "asio/detail/bind_handler.hpp" -#include "asio/detail/consuming_buffers.hpp" -#include "asio/detail/dependent_type.hpp" -#include "asio/detail/handler_alloc_helpers.hpp" -#include "asio/detail/handler_cont_helpers.hpp" -#include "asio/detail/handler_invoke_helpers.hpp" -#include "asio/detail/handler_type_requirements.hpp" -#include "asio/detail/throw_error.hpp" -#include "asio/error.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { - -template -std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers, - CompletionCondition completion_condition, asio::error_code& ec) -{ - ec = asio::error_code(); - asio::detail::consuming_buffers< - mutable_buffer, MutableBufferSequence> tmp(buffers); - std::size_t total_transferred = 0; - tmp.prepare(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - while (tmp.begin() != tmp.end()) - { - std::size_t bytes_transferred = s.read_some(tmp, ec); - tmp.consume(bytes_transferred); - total_transferred += bytes_transferred; - tmp.prepare(detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred))); - } - return total_transferred; -} - -template -inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers) -{ - asio::error_code ec; - std::size_t bytes_transferred = read(s, buffers, transfer_all(), ec); - asio::detail::throw_error(ec, "read"); - return bytes_transferred; -} - -template -inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers, - asio::error_code& ec) -{ - return read(s, buffers, transfer_all(), ec); -} - -template -inline std::size_t read(SyncReadStream& s, const MutableBufferSequence& buffers, - CompletionCondition completion_condition) -{ - asio::error_code ec; - std::size_t bytes_transferred = read(s, buffers, completion_condition, ec); - asio::detail::throw_error(ec, "read"); - return bytes_transferred; -} - -#if !defined(ASIO_NO_IOSTREAM) - -template -std::size_t read(SyncReadStream& s, - asio::basic_streambuf& b, - CompletionCondition completion_condition, asio::error_code& ec) -{ - ec = asio::error_code(); - std::size_t total_transferred = 0; - std::size_t max_size = detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred)); - std::size_t bytes_available = read_size_helper(b, max_size); - while (bytes_available > 0) - { - std::size_t bytes_transferred = s.read_some(b.prepare(bytes_available), ec); - b.commit(bytes_transferred); - total_transferred += bytes_transferred; - max_size = detail::adapt_completion_condition_result( - completion_condition(ec, total_transferred)); - bytes_available = read_size_helper(b, max_size); - } - return total_transferred; -} - -template -inline std::size_t read(SyncReadStream& s, - asio::basic_streambuf& b) -{ - asio::error_code ec; - std::size_t bytes_transferred = read(s, b, transfer_all(), ec); - asio::detail::throw_error(ec, "read"); - return bytes_transferred; -} - -template -inline std::size_t read(SyncReadStream& s, - asio::basic_streambuf& b, - asio::error_code& ec) -{ - return read(s, b, transfer_all(), ec); -} - -template -inline std::size_t read(SyncReadStream& s, - asio::basic_streambuf& b, - CompletionCondition completion_condition) -{ - asio::error_code ec; - std::size_t bytes_transferred = read(s, b, completion_condition, ec); - asio::detail::throw_error(ec, "read"); - return bytes_transferred; -} - -#endif // !defined(ASIO_NO_IOSTREAM) - -namespace detail -{ - template - class read_op - : detail::base_from_completion_cond - { - public: - read_op(AsyncReadStream& stream, const MutableBufferSequence& buffers, - CompletionCondition completion_condition, ReadHandler& handler) - : detail::base_from_completion_cond< - CompletionCondition>(completion_condition), - stream_(stream), - buffers_(buffers), - start_(0), - total_transferred_(0), - handler_(ASIO_MOVE_CAST(ReadHandler)(handler)) - { - } - -#if defined(ASIO_HAS_MOVE) - read_op(const read_op& other) - : detail::base_from_completion_cond(other), - stream_(other.stream_), - buffers_(other.buffers_), - start_(other.start_), - total_transferred_(other.total_transferred_), - handler_(other.handler_) - { - } - - read_op(read_op&& other) - : detail::base_from_completion_cond(other), - stream_(other.stream_), - buffers_(other.buffers_), - start_(other.start_), - total_transferred_(other.total_transferred_), - handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_)) - { - } -#endif // defined(ASIO_HAS_MOVE) - - void operator()(const asio::error_code& ec, - std::size_t bytes_transferred, int start = 0) - { - switch (start_ = start) - { - case 1: - buffers_.prepare(this->check_for_completion(ec, total_transferred_)); - for (;;) - { - stream_.async_read_some(buffers_, - ASIO_MOVE_CAST(read_op)(*this)); - return; default: - total_transferred_ += bytes_transferred; - buffers_.consume(bytes_transferred); - buffers_.prepare(this->check_for_completion(ec, total_transferred_)); - if ((!ec && bytes_transferred == 0) - || buffers_.begin() == buffers_.end()) - break; - } - - handler_(ec, static_cast(total_transferred_)); - } - } - - //private: - AsyncReadStream& stream_; - asio::detail::consuming_buffers< - mutable_buffer, MutableBufferSequence> buffers_; - int start_; - std::size_t total_transferred_; - ReadHandler handler_; - }; - - template - class read_op - : detail::base_from_completion_cond - { - public: - read_op(AsyncReadStream& stream, - const asio::mutable_buffers_1& buffers, - CompletionCondition completion_condition, ReadHandler& handler) - : detail::base_from_completion_cond< - CompletionCondition>(completion_condition), - stream_(stream), - buffer_(buffers), - start_(0), - total_transferred_(0), - handler_(ASIO_MOVE_CAST(ReadHandler)(handler)) - { - } - -#if defined(ASIO_HAS_MOVE) - read_op(const read_op& other) - : detail::base_from_completion_cond(other), - stream_(other.stream_), - buffer_(other.buffer_), - start_(other.start_), - total_transferred_(other.total_transferred_), - handler_(other.handler_) - { - } - - read_op(read_op&& other) - : detail::base_from_completion_cond(other), - stream_(other.stream_), - buffer_(other.buffer_), - start_(other.start_), - total_transferred_(other.total_transferred_), - handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_)) - { - } -#endif // defined(ASIO_HAS_MOVE) - - void operator()(const asio::error_code& ec, - std::size_t bytes_transferred, int start = 0) - { - std::size_t n = 0; - switch (start_ = start) - { - case 1: - n = this->check_for_completion(ec, total_transferred_); - for (;;) - { - stream_.async_read_some( - asio::buffer(buffer_ + total_transferred_, n), - ASIO_MOVE_CAST(read_op)(*this)); - return; default: - total_transferred_ += bytes_transferred; - if ((!ec && bytes_transferred == 0) - || (n = this->check_for_completion(ec, total_transferred_)) == 0 - || total_transferred_ == asio::buffer_size(buffer_)) - break; - } - - handler_(ec, static_cast(total_transferred_)); - } - } - - //private: - AsyncReadStream& stream_; - asio::mutable_buffer buffer_; - int start_; - std::size_t total_transferred_; - ReadHandler handler_; - }; - - template - class read_op, - CompletionCondition, ReadHandler> - : detail::base_from_completion_cond - { - public: - read_op(AsyncReadStream& stream, const boost::array& buffers, - CompletionCondition completion_condition, ReadHandler& handler) - : detail::base_from_completion_cond< - CompletionCondition>(completion_condition), - stream_(stream), - buffers_(buffers), - start_(0), - total_transferred_(0), - handler_(ASIO_MOVE_CAST(ReadHandler)(handler)) - { - } - -#if defined(ASIO_HAS_MOVE) - read_op(const read_op& other) - : detail::base_from_completion_cond(other), - stream_(other.stream_), - buffers_(other.buffers_), - start_(other.start_), - total_transferred_(other.total_transferred_), - handler_(other.handler_) - { - } - - read_op(read_op&& other) - : detail::base_from_completion_cond(other), - stream_(other.stream_), - buffers_(other.buffers_), - start_(other.start_), - total_transferred_(other.total_transferred_), - handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_)) - { - } -#endif // defined(ASIO_HAS_MOVE) - - void operator()(const asio::error_code& ec, - std::size_t bytes_transferred, int start = 0) - { - typename asio::detail::dependent_type >::type bufs = {{ - asio::mutable_buffer(buffers_[0]), - asio::mutable_buffer(buffers_[1]) }}; - std::size_t buffer_size0 = asio::buffer_size(bufs[0]); - std::size_t buffer_size1 = asio::buffer_size(bufs[1]); - std::size_t n = 0; - switch (start_ = start) - { - case 1: - n = this->check_for_completion(ec, total_transferred_); - for (;;) - { - bufs[0] = asio::buffer(bufs[0] + total_transferred_, n); - bufs[1] = asio::buffer( - bufs[1] + (total_transferred_ < buffer_size0 - ? 0 : total_transferred_ - buffer_size0), - n - asio::buffer_size(bufs[0])); - stream_.async_read_some(bufs, ASIO_MOVE_CAST(read_op)(*this)); - return; default: - total_transferred_ += bytes_transferred; - if ((!ec && bytes_transferred == 0) - || (n = this->check_for_completion(ec, total_transferred_)) == 0 - || total_transferred_ == buffer_size0 + buffer_size1) - break; - } - - handler_(ec, static_cast(total_transferred_)); - } - } - - //private: - AsyncReadStream& stream_; - boost::array buffers_; - int start_; - std::size_t total_transferred_; - ReadHandler handler_; - }; - -#if defined(ASIO_HAS_STD_ARRAY) - - template - class read_op, - CompletionCondition, ReadHandler> - : detail::base_from_completion_cond - { - public: - read_op(AsyncReadStream& stream, const std::array& buffers, - CompletionCondition completion_condition, ReadHandler& handler) - : detail::base_from_completion_cond< - CompletionCondition>(completion_condition), - stream_(stream), - buffers_(buffers), - start_(0), - total_transferred_(0), - handler_(ASIO_MOVE_CAST(ReadHandler)(handler)) - { - } - -#if defined(ASIO_HAS_MOVE) - read_op(const read_op& other) - : detail::base_from_completion_cond(other), - stream_(other.stream_), - buffers_(other.buffers_), - start_(other.start_), - total_transferred_(other.total_transferred_), - handler_(other.handler_) - { - } - - read_op(read_op&& other) - : detail::base_from_completion_cond(other), - stream_(other.stream_), - buffers_(other.buffers_), - start_(other.start_), - total_transferred_(other.total_transferred_), - handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_)) - { - } -#endif // defined(ASIO_HAS_MOVE) - - void operator()(const asio::error_code& ec, - std::size_t bytes_transferred, int start = 0) - { - typename asio::detail::dependent_type >::type bufs = {{ - asio::mutable_buffer(buffers_[0]), - asio::mutable_buffer(buffers_[1]) }}; - std::size_t buffer_size0 = asio::buffer_size(bufs[0]); - std::size_t buffer_size1 = asio::buffer_size(bufs[1]); - std::size_t n = 0; - switch (start_ = start) - { - case 1: - n = this->check_for_completion(ec, total_transferred_); - for (;;) - { - bufs[0] = asio::buffer(bufs[0] + total_transferred_, n); - bufs[1] = asio::buffer( - bufs[1] + (total_transferred_ < buffer_size0 - ? 0 : total_transferred_ - buffer_size0), - n - asio::buffer_size(bufs[0])); - stream_.async_read_some(bufs, ASIO_MOVE_CAST(read_op)(*this)); - return; default: - total_transferred_ += bytes_transferred; - if ((!ec && bytes_transferred == 0) - || (n = this->check_for_completion(ec, total_transferred_)) == 0 - || total_transferred_ == buffer_size0 + buffer_size1) - break; - } - - handler_(ec, static_cast(total_transferred_)); - } - } - - //private: - AsyncReadStream& stream_; - std::array buffers_; - int start_; - std::size_t total_transferred_; - ReadHandler handler_; - }; - -#endif // defined(ASIO_HAS_STD_ARRAY) - - template - inline void* asio_handler_allocate(std::size_t size, - read_op* this_handler) - { - return asio_handler_alloc_helpers::allocate( - size, this_handler->handler_); - } - - template - inline void asio_handler_deallocate(void* pointer, std::size_t size, - read_op* this_handler) - { - asio_handler_alloc_helpers::deallocate( - pointer, size, this_handler->handler_); - } - - template - inline bool asio_handler_is_continuation( - read_op* this_handler) - { - return this_handler->start_ == 0 ? true - : asio_handler_cont_helpers::is_continuation( - this_handler->handler_); - } - - template - inline void asio_handler_invoke(Function& function, - read_op* this_handler) - { - asio_handler_invoke_helpers::invoke( - function, this_handler->handler_); - } - - template - inline void asio_handler_invoke(const Function& function, - read_op* this_handler) - { - asio_handler_invoke_helpers::invoke( - function, this_handler->handler_); - } -} // namespace detail - -template -inline ASIO_INITFN_RESULT_TYPE(ReadHandler, - void (asio::error_code, std::size_t)) -async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, - CompletionCondition completion_condition, - ASIO_MOVE_ARG(ReadHandler) handler) -{ - // If you get an error on the following line it means that your handler does - // not meet the documented type requirements for a ReadHandler. - ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; - - detail::async_result_init< - ReadHandler, void (asio::error_code, std::size_t)> init( - ASIO_MOVE_CAST(ReadHandler)(handler)); - - detail::read_op( - s, buffers, completion_condition, init.handler)( - asio::error_code(), 0, 1); - - return init.result.get(); -} - -template -inline ASIO_INITFN_RESULT_TYPE(ReadHandler, - void (asio::error_code, std::size_t)) -async_read(AsyncReadStream& s, const MutableBufferSequence& buffers, - ASIO_MOVE_ARG(ReadHandler) handler) -{ - // If you get an error on the following line it means that your handler does - // not meet the documented type requirements for a ReadHandler. - ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; - - detail::async_result_init< - ReadHandler, void (asio::error_code, std::size_t)> init( - ASIO_MOVE_CAST(ReadHandler)(handler)); - - detail::read_op( - s, buffers, transfer_all(), init.handler)( - asio::error_code(), 0, 1); - - return init.result.get(); -} - -#if !defined(ASIO_NO_IOSTREAM) - -namespace detail -{ - template - class read_streambuf_op - : detail::base_from_completion_cond - { - public: - read_streambuf_op(AsyncReadStream& stream, - basic_streambuf& streambuf, - CompletionCondition completion_condition, ReadHandler& handler) - : detail::base_from_completion_cond< - CompletionCondition>(completion_condition), - stream_(stream), - streambuf_(streambuf), - start_(0), - total_transferred_(0), - handler_(ASIO_MOVE_CAST(ReadHandler)(handler)) - { - } - -#if defined(ASIO_HAS_MOVE) - read_streambuf_op(const read_streambuf_op& other) - : detail::base_from_completion_cond(other), - stream_(other.stream_), - streambuf_(other.streambuf_), - start_(other.start_), - total_transferred_(other.total_transferred_), - handler_(other.handler_) - { - } - - read_streambuf_op(read_streambuf_op&& other) - : detail::base_from_completion_cond(other), - stream_(other.stream_), - streambuf_(other.streambuf_), - start_(other.start_), - total_transferred_(other.total_transferred_), - handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_)) - { - } -#endif // defined(ASIO_HAS_MOVE) - - void operator()(const asio::error_code& ec, - std::size_t bytes_transferred, int start = 0) - { - std::size_t max_size, bytes_available; - switch (start_ = start) - { - case 1: - max_size = this->check_for_completion(ec, total_transferred_); - bytes_available = read_size_helper(streambuf_, max_size); - for (;;) - { - stream_.async_read_some(streambuf_.prepare(bytes_available), - ASIO_MOVE_CAST(read_streambuf_op)(*this)); - return; default: - total_transferred_ += bytes_transferred; - streambuf_.commit(bytes_transferred); - max_size = this->check_for_completion(ec, total_transferred_); - bytes_available = read_size_helper(streambuf_, max_size); - if ((!ec && bytes_transferred == 0) || bytes_available == 0) - break; - } - - handler_(ec, static_cast(total_transferred_)); - } - } - - //private: - AsyncReadStream& stream_; - asio::basic_streambuf& streambuf_; - int start_; - std::size_t total_transferred_; - ReadHandler handler_; - }; - - template - inline void* asio_handler_allocate(std::size_t size, - read_streambuf_op* this_handler) - { - return asio_handler_alloc_helpers::allocate( - size, this_handler->handler_); - } - - template - inline void asio_handler_deallocate(void* pointer, std::size_t size, - read_streambuf_op* this_handler) - { - asio_handler_alloc_helpers::deallocate( - pointer, size, this_handler->handler_); - } - - template - inline bool asio_handler_is_continuation( - read_streambuf_op* this_handler) - { - return this_handler->start_ == 0 ? true - : asio_handler_cont_helpers::is_continuation( - this_handler->handler_); - } - - template - inline void asio_handler_invoke(Function& function, - read_streambuf_op* this_handler) - { - asio_handler_invoke_helpers::invoke( - function, this_handler->handler_); - } - - template - inline void asio_handler_invoke(const Function& function, - read_streambuf_op* this_handler) - { - asio_handler_invoke_helpers::invoke( - function, this_handler->handler_); - } -} // namespace detail - -template -inline ASIO_INITFN_RESULT_TYPE(ReadHandler, - void (asio::error_code, std::size_t)) -async_read(AsyncReadStream& s, - asio::basic_streambuf& b, - CompletionCondition completion_condition, - ASIO_MOVE_ARG(ReadHandler) handler) -{ - // If you get an error on the following line it means that your handler does - // not meet the documented type requirements for a ReadHandler. - ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; - - detail::async_result_init< - ReadHandler, void (asio::error_code, std::size_t)> init( - ASIO_MOVE_CAST(ReadHandler)(handler)); - - detail::read_streambuf_op( - s, b, completion_condition, init.handler)( - asio::error_code(), 0, 1); - - return init.result.get(); -} - -template -inline ASIO_INITFN_RESULT_TYPE(ReadHandler, - void (asio::error_code, std::size_t)) -async_read(AsyncReadStream& s, - asio::basic_streambuf& b, - ASIO_MOVE_ARG(ReadHandler) handler) -{ - // If you get an error on the following line it means that your handler does - // not meet the documented type requirements for a ReadHandler. - ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; - - detail::async_result_init< - ReadHandler, void (asio::error_code, std::size_t)> init( - ASIO_MOVE_CAST(ReadHandler)(handler)); - - detail::read_streambuf_op( - s, b, transfer_all(), init.handler)( - asio::error_code(), 0, 1); - - return init.result.get(); -} - -#endif // !defined(ASIO_NO_IOSTREAM) - -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_IMPL_READ_HPP