Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit663277e

Browse files
committed
replace std::promise/std::shared_future with boost equivalents
boost::shared_future has a richer api, notably it has the `is_ready()`method required by the `ready()` wrapper
1 parent5237c2f commit663277e

File tree

13 files changed

+52
-50
lines changed

13 files changed

+52
-50
lines changed

‎CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ add_definitions(-DBOOST_TEST_DYN_LINK)
4545
# Always use multi-threaded Boost libraries.
4646
set(Boost_USE_MULTI_THREADEDON)
4747

48-
find_package(Boost1.58.0REQUIREDCOMPONENTSsystem)
48+
find_package(Boost1.58.0REQUIREDCOMPONENTSsystemthread)
4949

5050
if (CPP-NETLIB_ENABLE_HTTPS)
5151
if (APPLE)

‎boost/network/message/directives/detail/string_value.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9-
#include<future>
109
#include<boost/network/traits/string.hpp>
1110
#include<boost/network/support/is_async.hpp>
1211
#include<boost/network/support/is_sync.hpp>
12+
#include<boost/thread/future.hpp>
1313
#include<boost/type_traits/is_same.hpp>
1414
#include<boost/mpl/if.hpp>
1515
#include<boost/mpl/or.hpp>
@@ -20,7 +20,7 @@ namespace detail {
2020

2121
template<classTag>
2222
structstring_value
23-
: mpl::if_<is_async<Tag>,std::shared_future<typename string<Tag>::type>,
23+
: mpl::if_<is_async<Tag>,boost::shared_future<typename string<Tag>::type>,
2424
typename mpl::if_<
2525
mpl::or_<is_sync<Tag>, is_same<Tag, tags::default_string>,
2626
is_same<Tag, tags::default_wstring> >,

‎boost/network/message/modifiers/clear_headers.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9-
#include<future>
109
#include<boost/mpl/and.hpp>
1110
#include<boost/mpl/not.hpp>
1211
#include<boost/network/support/is_async.hpp>
1312
#include<boost/network/support/is_pod.hpp>
13+
#include<boost/thread/future.hpp>
1414
#include<boost/utility/enable_if.hpp>
1515

1616
namespaceboost {
@@ -34,8 +34,8 @@ template <class Message, class Tag>
3434
inlinetypename enable_if<mpl::and_<mpl::not_<is_pod<Tag> >, is_async<Tag> >,
3535
void>::type
3636
clear_headers(Messageconst &message, Tagconst &) {
37-
std::promise<typename Message::headers_container_type> header_promise;
38-
std::shared_future<typename Message::headers_container_type>headers_future(
37+
boost::promise<typename Message::headers_container_type> header_promise;
38+
boost::shared_future<typename Message::headers_container_type>headers_future(
3939
header_promise.get_future());
4040
message.headers(headers_future);
4141
header_promise.set_value(typenameMessage::headers_container_type());

‎boost/network/message/traits/body.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
// (See accompanying file LICENSE_1_0.txt or copy at
99
// http://www.boost.org/LICENSE_1_0.txt)
1010

11-
#include<future>
1211
#include<boost/mpl/if.hpp>
1312
#include<boost/network/support/is_async.hpp>
1413
#include<boost/network/support/is_sync.hpp>
1514
#include<boost/network/tags.hpp>
1615
#include<boost/network/traits/string.hpp>
16+
#include<boost/thread/future.hpp>
1717
#include<boost/type_traits/is_same.hpp>
1818

1919
namespaceboost {
@@ -27,7 +27,7 @@ template <class Message>
2727
structbody
2828
: mpl::if_<
2929
is_async<typename Message::tag>,
30-
std::shared_future<typename string<typename Message::tag>::type>,
30+
boost::shared_future<typename string<typename Message::tag>::type>,
3131
typename mpl::if_<
3232
mpl::or_<is_sync<typename Message::tag>,
3333
is_same<typename Message::tag,

‎boost/network/message/traits/destination.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
// (See accompanying file LICENSE_1_0.txt or copy at
88
// http://www.boost.org/LICENSE_1_0.txt)
99

10-
#include<future>
1110
#include<boost/mpl/if.hpp>
1211
#include<boost/network/support/is_async.hpp>
1312
#include<boost/network/support/is_sync.hpp>
1413
#include<boost/network/tags.hpp>
1514
#include<boost/network/traits/string.hpp>
15+
#include<boost/thread/future.hpp>
1616
#include<boost/type_traits/is_same.hpp>
1717

1818
namespaceboost {
@@ -26,7 +26,7 @@ struct unsupported_tag;
2626
template<classMessage>
2727
structdestination
2828
: mpl::if_<is_async<typename Message::tag>,
29-
std::shared_future<typename string<typename Message::tag>::type>,
29+
boost::shared_future<typename string<typename Message::tag>::type>,
3030
typename mpl::if_<
3131
mpl::or_<is_sync<typename Message::tag>,
3232
is_same<typename Message::tag,

‎boost/network/message/traits/headers.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
// (See accompanying file LICENSE_1_0.txt or copy at
88
// http://www.boost.org/LICENSE_1_0.txt)
99

10-
#include<future>
1110
#include<boost/mpl/if.hpp>
1211
#include<boost/mpl/or.hpp>
1312
#include<boost/network/message/directives.hpp>
1413
#include<boost/network/message/transformers.hpp>
1514
#include<boost/network/message/wrappers.hpp>
1615
#include<boost/network/support/is_async.hpp>
1716
#include<boost/network/support/is_sync.hpp>
17+
#include<boost/thread/future.hpp>
1818

1919
namespaceboost {
2020
namespacenetwork {
@@ -28,7 +28,7 @@ template <class Message>
2828
structheader_key
2929
: mpl::if_<
3030
is_async<typename Message::tag>,
31-
std::shared_future<typename string<typename Message::tag>::type>,
31+
boost::shared_future<typename string<typename Message::tag>::type>,
3232
typename mpl::if_<
3333
mpl::or_<is_sync<typename Message::tag>,
3434
is_same<typename Message::tag, tags::default_string>,
@@ -40,7 +40,7 @@ template <class Message>
4040
structheader_value
4141
: mpl::if_<
4242
is_async<typename Message::tag>,
43-
std::shared_future<typename string<typename Message::tag>::type>,
43+
boost::shared_future<typename string<typename Message::tag>::type>,
4444
typename mpl::if_<
4545
mpl::or_<is_sync<typename Message::tag>,
4646
is_same<typename Message::tag, tags::default_string>,

‎boost/network/message/traits/source.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9-
#include<future>
109
#include<boost/mpl/if.hpp>
1110
#include<boost/network/support/is_async.hpp>
1211
#include<boost/network/support/is_sync.hpp>
1312
#include<boost/network/tags.hpp>
1413
#include<boost/network/traits/string.hpp>
14+
#include<boost/thread/future.hpp>
1515
#include<boost/type_traits/is_same.hpp>
1616

1717
namespaceboost {
@@ -24,7 +24,7 @@ struct unsupported_tag;
2424
template<classMessage>
2525
structsource
2626
: mpl::if_<is_async<typename Message::tag>,
27-
std::shared_future<typename string<typename Message::tag>::type>,
27+
boost::shared_future<typename string<typename Message::tag>::type>,
2828
typename mpl::if_<
2929
mpl::or_<is_sync<typename Message::tag>,
3030
is_same<typename Message::tag,

‎boost/network/protocol/http/client/connection/async_protocol_handler.hpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include<boost/network/protocol/http/parser/incremental.hpp>
1818
#include<boost/network/protocol/http/request_parser.hpp>
1919
#include<boost/network/traits/string.hpp>
20+
#include<boost/thread/future.hpp>
2021

2122
namespaceboost {
2223
namespacenetwork {
@@ -57,30 +58,30 @@ struct http_async_protocol_handler {
5758
// TODO(dberris): review parameter necessity.
5859
(void)get_body;
5960

60-
std::shared_future<string_type>source_future(
61+
boost::shared_future<string_type>source_future(
6162
source_promise.get_future());
6263
source(response_, source_future);
6364

64-
std::shared_future<string_type>destination_future(
65+
boost::shared_future<string_type>destination_future(
6566
destination_promise.get_future());
6667
destination(response_, destination_future);
6768

68-
std::shared_future<typename headers_container<Tag>::type>headers_future(
69+
boost::shared_future<typename headers_container<Tag>::type>headers_future(
6970
headers_promise.get_future());
7071
headers(response_, headers_future);
7172

72-
std::shared_future<string_type>body_future(body_promise.get_future());
73+
boost::shared_future<string_type>body_future(body_promise.get_future());
7374
body(response_, body_future);
7475

75-
std::shared_future<string_type>version_future(
76+
boost::shared_future<string_type>version_future(
7677
version_promise.get_future());
7778
version(response_, version_future);
7879

79-
std::shared_future<std::uint16_t>status_future(
80+
boost::shared_future<std::uint16_t>status_future(
8081
status_promise.get_future());
8182
status(response_, status_future);
8283

83-
std::shared_future<string_type>status_message_future(
84+
boost::shared_future<string_type>status_message_future(
8485
status_message_promise.get_future());
8586
status_message(response_, status_message_future);
8687
}
@@ -339,13 +340,13 @@ struct http_async_protocol_handler {
339340
typedef std::array<typename char_<Tag>::type,1024> buffer_type;
340341

341342
response_parser_type response_parser_;
342-
std::promise<string_type> version_promise;
343-
std::promise<std::uint16_t> status_promise;
344-
std::promise<string_type> status_message_promise;
345-
std::promise<typename headers_container<Tag>::type> headers_promise;
346-
std::promise<string_type> source_promise;
347-
std::promise<string_type> destination_promise;
348-
std::promise<string_type> body_promise;
343+
boost::promise<string_type> version_promise;
344+
boost::promise<std::uint16_t> status_promise;
345+
boost::promise<string_type> status_message_promise;
346+
boost::promise<typename headers_container<Tag>::type> headers_promise;
347+
boost::promise<string_type> source_promise;
348+
boost::promise<string_type> destination_promise;
349+
boost::promise<string_type> body_promise;
349350
buffer_type part;
350351
typename buffer_type::const_iterator part_begin;
351352
string_type partial_parsed;

‎boost/network/protocol/http/message/async_message.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
// (See accompanying file LICENSE_1_0.txt or copy at
1010
// http://www.boost.org/LICENSE_1_0.txt)
1111

12-
#include<future>
1312
#include<cstdint>
1413
#include<boost/optional.hpp>
1514

1615
// FIXME move this out to a trait
1716
#include<set>
1817
#include<boost/network/detail/wrapper_base.hpp>
18+
#include<boost/thread/future.hpp>
1919

2020
namespaceboost {
2121
namespacenetwork {
@@ -56,31 +56,31 @@ struct async_message {
5656

5757
string_typeconststatus_message()const {return status_message_.get(); }
5858

59-
voidstatus_message(std::shared_future<string_type>const& future)const {
59+
voidstatus_message(boost::shared_future<string_type>const& future)const {
6060
status_message_ = future;
6161
}
6262

6363
string_typeconstversion()const {return version_.get(); }
6464

65-
voidversion(std::shared_future<string_type>const& future)const {
65+
voidversion(boost::shared_future<string_type>const& future)const {
6666
version_ = future;
6767
}
6868

6969
std::uint16_tstatus()const {return status_.get(); }
7070

71-
voidstatus(std::shared_future<uint16_t>const& future)const {
71+
voidstatus(boost::shared_future<uint16_t>const& future)const {
7272
status_ = future;
7373
}
7474

7575
string_typeconstsource()const {return source_.get(); }
7676

77-
voidsource(std::shared_future<string_type>const& future)const {
77+
voidsource(boost::shared_future<string_type>const& future)const {
7878
source_ = future;
7979
}
8080

8181
string_typeconstdestination()const {return destination_.get(); }
8282

83-
voiddestination(std::shared_future<string_type>const& future)const {
83+
voiddestination(boost::shared_future<string_type>const& future)const {
8484
destination_ = future;
8585
}
8686

@@ -95,7 +95,7 @@ struct async_message {
9595
return *retrieved_headers_;
9696
}
9797

98-
voidheaders(std::shared_future<headers_container_type>const& future)
98+
voidheaders(boost::shared_future<headers_container_type>const& future)
9999
const {
100100
headers_ = future;
101101
}
@@ -112,7 +112,7 @@ struct async_message {
112112

113113
string_typeconstbody()const {return body_.get(); }
114114

115-
voidbody(std::shared_future<string_type>const& future)const {
115+
voidbody(boost::shared_future<string_type>const& future)const {
116116
body_ = future;
117117
}
118118

@@ -132,13 +132,13 @@ struct async_message {
132132
}
133133

134134
private:
135-
mutablestd::shared_future<string_type> status_message_, version_, source_,
135+
mutableboost::shared_future<string_type> status_message_, version_, source_,
136136
destination_;
137-
mutablestd::shared_future<std::uint16_t> status_;
138-
mutablestd::shared_future<headers_container_type> headers_;
137+
mutableboost::shared_future<std::uint16_t> status_;
138+
mutableboost::shared_future<headers_container_type> headers_;
139139
mutable headers_container_type added_headers;
140140
mutable std::set<string_type> removed_headers;
141-
mutablestd::shared_future<string_type> body_;
141+
mutableboost::shared_future<string_type> body_;
142142
mutable boost::optional<headers_container_type> retrieved_headers_;
143143

144144
friendstructboost::network::http::impl::ready_wrapper<Tag>;

‎boost/network/protocol/http/message/directives/status.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
// (See accompanying file LICENSE_1_0.txt or copy at
88
// http://www.boost.org/LICENSE_1_0.txt)
99

10-
#include<future>
1110
#include<cstdint>
1211
#include<boost/mpl/if.hpp>
1312
#include<boost/network/support/is_async.hpp>
1413
#include<boost/network/tags.hpp>
14+
#include<boost/thread/future.hpp>
1515
#include<boost/variant/apply_visitor.hpp>
1616
#include<boost/variant/static_visitor.hpp>
1717
#include<boost/variant/variant.hpp>
@@ -25,18 +25,18 @@ struct basic_response;
2525

2626
structstatus_directive {
2727

28-
boost::variant<std::uint16_t,std::shared_future<std::uint16_t> >
28+
boost::variant<std::uint16_t,boost::shared_future<std::uint16_t> >
2929
status_;
3030

3131
explicitstatus_directive(std::uint16_t status) : status_(status) {}
3232

33-
explicitstatus_directive(std::shared_future<std::uint16_t>const &status)
33+
explicitstatus_directive(boost::shared_future<std::uint16_t>const &status)
3434
: status_(status) {}
3535

3636
status_directive(status_directiveconst &other) : status_(other.status_) {}
3737

3838
template<classTag>
39-
structvalue : mpl::if_<is_async<Tag>,std::shared_future<std::uint16_t>,
39+
structvalue : mpl::if_<is_async<Tag>,boost::shared_future<std::uint16_t>,
4040
std::uint16_t> {};
4141

4242
template<classTag>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp