From 1d4e0fb0d5968224827b28da6ddd277b96880d5f Mon Sep 17 00:00:00 2001 From: Igor Peshansky Date: Fri, 25 May 2018 16:06:59 -0400 Subject: [PATCH] Switch from boost/thread/future.hpp to C++11 future. --- .../directives/detail/string_value.hpp | 4 +- .../message/modifiers/clear_headers.hpp | 7 ++-- boost/network/message/traits/body.hpp | 4 +- boost/network/message/traits/destination.hpp | 4 +- boost/network/message/traits/headers.hpp | 6 +-- boost/network/message/traits/source.hpp | 4 +- .../http/client/connection/async_normal.hpp | 14 +++---- .../connection/async_protocol_handler.hpp | 30 +++++++------- .../protocol/http/message/async_message.hpp | 39 ++++++------------- .../http/message/directives/status.hpp | 8 ++-- .../protocol/http/message/traits/status.hpp | 4 +- .../http/message/traits/status_message.hpp | 4 +- .../protocol/http/message/traits/version.hpp | 4 +- 13 files changed, 59 insertions(+), 73 deletions(-) diff --git a/boost/network/message/directives/detail/string_value.hpp b/boost/network/message/directives/detail/string_value.hpp index 8a3fa7d26..b16a56e2d 100644 --- a/boost/network/message/directives/detail/string_value.hpp +++ b/boost/network/message/directives/detail/string_value.hpp @@ -9,10 +9,10 @@ #include #include #include -#include #include #include #include +#include namespace boost { namespace network { @@ -20,7 +20,7 @@ namespace detail { template struct string_value - : mpl::if_, boost::shared_future::type>, + : mpl::if_, std::shared_future::type>, typename mpl::if_< mpl::or_, is_same, is_same >, diff --git a/boost/network/message/modifiers/clear_headers.hpp b/boost/network/message/modifiers/clear_headers.hpp index ef758073f..d6b601a52 100644 --- a/boost/network/message/modifiers/clear_headers.hpp +++ b/boost/network/message/modifiers/clear_headers.hpp @@ -10,9 +10,10 @@ #include #include #include -#include #include +#include + namespace boost { namespace network { @@ -34,8 +35,8 @@ template inline typename enable_if >, is_async >, void>::type clear_headers(Message const &message, Tag const &) { - boost::promise header_promise; - boost::shared_future headers_future( + std::promise header_promise; + std::shared_future headers_future( header_promise.get_future()); message.headers(headers_future); header_promise.set_value(typename Message::headers_container_type()); diff --git a/boost/network/message/traits/body.hpp b/boost/network/message/traits/body.hpp index cd0c56b1f..cba8fca24 100644 --- a/boost/network/message/traits/body.hpp +++ b/boost/network/message/traits/body.hpp @@ -13,8 +13,8 @@ #include #include #include -#include #include +#include namespace boost { namespace network { @@ -27,7 +27,7 @@ template struct body : mpl::if_< is_async, - boost::shared_future::type>, + std::shared_future::type>, typename mpl::if_< mpl::or_, is_same #include #include -#include #include +#include namespace boost { namespace network { @@ -26,7 +26,7 @@ struct unsupported_tag; template struct destination : mpl::if_, - boost::shared_future::type>, + std::shared_future::type>, typename mpl::if_< mpl::or_, is_same #include #include -#include +#include namespace boost { namespace network { @@ -28,7 +28,7 @@ template struct header_key : mpl::if_< is_async, - boost::shared_future::type>, + std::shared_future::type>, typename mpl::if_< mpl::or_, is_same, @@ -40,7 +40,7 @@ template struct header_value : mpl::if_< is_async, - boost::shared_future::type>, + std::shared_future::type>, typename mpl::if_< mpl::or_, is_same, diff --git a/boost/network/message/traits/source.hpp b/boost/network/message/traits/source.hpp index 17f9b188e..6f25f4e35 100644 --- a/boost/network/message/traits/source.hpp +++ b/boost/network/message/traits/source.hpp @@ -11,8 +11,8 @@ #include #include #include -#include #include +#include namespace boost { namespace network { @@ -24,7 +24,7 @@ struct unsupported_tag; template struct source : mpl::if_, - boost::shared_future::type>, + std::shared_future::type>, typename mpl::if_< mpl::or_, is_sameversion_promise.set_exception(boost::copy_exception(error)); - this->status_promise.set_exception(boost::copy_exception(error)); - this->status_message_promise.set_exception(boost::copy_exception(error)); - this->headers_promise.set_exception(boost::copy_exception(error)); - this->source_promise.set_exception(boost::copy_exception(error)); - this->destination_promise.set_exception(boost::copy_exception(error)); - this->body_promise.set_exception(boost::copy_exception(error)); + this->version_promise.set_exception(std::make_exception_ptr(error)); + this->status_promise.set_exception(std::make_exception_ptr(error)); + this->status_message_promise.set_exception(std::make_exception_ptr(error)); + this->headers_promise.set_exception(std::make_exception_ptr(error)); + this->source_promise.set_exception(std::make_exception_ptr(error)); + this->destination_promise.set_exception(std::make_exception_ptr(error)); + this->body_promise.set_exception(std::make_exception_ptr(error)); if ( callback ) callback( boost::iterator_range::type, 1024>::const_iterator>(), ec ); this->timer_.cancel(); diff --git a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp index a0ce75bce..4c92d5307 100644 --- a/boost/network/protocol/http/client/connection/async_protocol_handler.hpp +++ b/boost/network/protocol/http/client/connection/async_protocol_handler.hpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include namespace boost { namespace network { @@ -58,30 +58,30 @@ struct http_async_protocol_handler { // TODO(dberris): review parameter necessity. (void)get_body; - boost::shared_future source_future( + std::shared_future source_future( source_promise.get_future()); source(response_, source_future); - boost::shared_future destination_future( + std::shared_future destination_future( destination_promise.get_future()); destination(response_, destination_future); - boost::shared_future::type> headers_future( + std::shared_future::type> headers_future( headers_promise.get_future()); headers(response_, headers_future); - boost::shared_future body_future(body_promise.get_future()); + std::shared_future body_future(body_promise.get_future()); body(response_, body_future); - boost::shared_future version_future( + std::shared_future version_future( version_promise.get_future()); version(response_, version_future); - boost::shared_future status_future( + std::shared_future status_future( status_promise.get_future()); status(response_, status_future); - boost::shared_future status_message_future( + std::shared_future status_message_future( status_message_promise.get_future()); status_message(response_, status_message_future); } @@ -401,13 +401,13 @@ struct http_async_protocol_handler { typedef std::array::type, 1024> buffer_type; response_parser_type response_parser_; - boost::promise version_promise; - boost::promise status_promise; - boost::promise status_message_promise; - boost::promise::type> headers_promise; - boost::promise source_promise; - boost::promise destination_promise; - boost::promise body_promise; + std::promise version_promise; + std::promise status_promise; + std::promise status_message_promise; + std::promise::type> headers_promise; + std::promise source_promise; + std::promise destination_promise; + std::promise body_promise; buffer_type part; typename buffer_type::const_iterator part_begin; string_type partial_parsed; diff --git a/boost/network/protocol/http/message/async_message.hpp b/boost/network/protocol/http/message/async_message.hpp index 747a962ed..8ab41da8d 100644 --- a/boost/network/protocol/http/message/async_message.hpp +++ b/boost/network/protocol/http/message/async_message.hpp @@ -14,7 +14,7 @@ // FIXME move this out to a trait #include -#include +#include #include namespace boost { @@ -55,63 +55,51 @@ struct async_message { string_type status_message() const { status_message_.wait(); - if (status_message_.has_exception()) - boost::rethrow_exception(status_message_.get_exception_ptr()); return status_message_.get(); } - void status_message(boost::shared_future const& future) const { + void status_message(std::shared_future const& future) const { status_message_ = future; } string_type version() const { version_.wait(); - if (version_.has_exception()) - boost::rethrow_exception(version_.get_exception_ptr()); return version_.get(); } - void version(boost::shared_future const& future) const { + void version(std::shared_future const& future) const { version_ = future; } std::uint16_t status() const { status_.wait(); - if (status_.has_exception()) - boost::rethrow_exception(status_.get_exception_ptr()); return status_.get(); } - void status(boost::shared_future const& future) const { + void status(std::shared_future const& future) const { status_ = future; } string_type source() const { source_.wait(); - if (source_.has_exception()) - boost::rethrow_exception(source_.get_exception_ptr()); return source_.get(); } - void source(boost::shared_future const& future) const { + void source(std::shared_future const& future) const { source_ = future; } string_type destination() const { destination_.wait(); - if (destination_.has_exception()) - boost::rethrow_exception(source_.get_exception_ptr()); return destination_.get(); } - void destination(boost::shared_future const& future) const { + void destination(std::shared_future const& future) const { destination_ = future; } headers_container_type const& headers() const { if (retrieved_headers_) return *retrieved_headers_; - if (headers_.has_exception()) - boost::rethrow_exception(headers_.get_exception_ptr()); headers_container_type raw_headers = headers_.get(); raw_headers.insert(added_headers.begin(), added_headers.end()); for (string_type const& key : removed_headers) { @@ -121,8 +109,7 @@ struct async_message { return *retrieved_headers_; } - void headers( - boost::shared_future const& future) const { + void headers(std::shared_future const& future) const { headers_ = future; } @@ -138,12 +125,10 @@ struct async_message { string_type body() const { body_.wait(); - if (body_.has_exception()) - boost::rethrow_exception(body_.get_exception_ptr()); return body_.get(); } - void body(boost::shared_future const& future) const { + void body(std::shared_future const& future) const { body_ = future; } @@ -163,13 +148,13 @@ struct async_message { } private: - mutable boost::shared_future status_message_, version_, source_, + mutable std::shared_future status_message_, version_, source_, destination_; - mutable boost::shared_future status_; - mutable boost::shared_future headers_; + mutable std::shared_future status_; + mutable std::shared_future headers_; mutable headers_container_type added_headers; mutable std::set removed_headers; - mutable boost::shared_future body_; + mutable std::shared_future body_; mutable boost::optional retrieved_headers_; friend struct boost::network::http::impl::ready_wrapper; diff --git a/boost/network/protocol/http/message/directives/status.hpp b/boost/network/protocol/http/message/directives/status.hpp index f64cb94d3..b8f9d744a 100644 --- a/boost/network/protocol/http/message/directives/status.hpp +++ b/boost/network/protocol/http/message/directives/status.hpp @@ -11,10 +11,10 @@ #include #include #include -#include #include #include #include +#include namespace boost { namespace network { @@ -25,18 +25,18 @@ struct basic_response; struct status_directive { - boost::variant > + boost::variant > status_; explicit status_directive(std::uint16_t status) : status_(status) {} - explicit status_directive(boost::shared_future const &status) + explicit status_directive(std::shared_future const &status) : status_(status) {} status_directive(status_directive const &other) : status_(other.status_) {} template - struct value : mpl::if_, boost::shared_future, + struct value : mpl::if_, std::shared_future, std::uint16_t> {}; template diff --git a/boost/network/protocol/http/message/traits/status.hpp b/boost/network/protocol/http/message/traits/status.hpp index 92c6c3d6c..3710568f1 100644 --- a/boost/network/protocol/http/message/traits/status.hpp +++ b/boost/network/protocol/http/message/traits/status.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include namespace boost { namespace network { @@ -24,7 +24,7 @@ template struct status : mpl::if_< is_async, - boost::shared_future, + std::shared_future, typename mpl::if_, std::uint16_t, unsupported_tag >::type> {}; diff --git a/boost/network/protocol/http/message/traits/status_message.hpp b/boost/network/protocol/http/message/traits/status_message.hpp index 61b89ec02..7f3fe3dba 100644 --- a/boost/network/protocol/http/message/traits/status_message.hpp +++ b/boost/network/protocol/http/message/traits/status_message.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace boost { namespace network { @@ -25,7 +25,7 @@ template struct status_message : mpl::if_< is_async, - boost::shared_future::type>, + std::shared_future::type>, typename mpl::if_< mpl::or_, is_same, diff --git a/boost/network/protocol/http/message/traits/version.hpp b/boost/network/protocol/http/message/traits/version.hpp index 3fbcc7348..614612af1 100644 --- a/boost/network/protocol/http/message/traits/version.hpp +++ b/boost/network/protocol/http/message/traits/version.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace boost { namespace network { @@ -30,7 +30,7 @@ struct version { template struct version >::type> { - typedef boost::shared_future::type> + typedef std::shared_future::type> type; }; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy