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

Commit8a4c1a0

Browse files
committed
Replaced boost::thread with std::thread.
1 parentb3adea8 commit8a4c1a0

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

‎boost/network/protocol/http/client/async_impl.hpp‎

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

11+
#include<thread>
1112
#include<boost/asio/io_service.hpp>
1213
#include<boost/asio/strand.hpp>
1314
#include<boost/bind.hpp>
1415
#include<boost/make_shared.hpp>
1516
#include<boost/network/protocol/http/traits/connection_policy.hpp>
1617
#include<boost/shared_ptr.hpp>
17-
#include<boost/thread/thread.hpp>
1818

1919
namespaceboost {
2020
namespacenetwork {
@@ -62,8 +62,7 @@ struct async_client
6262
connection_base::resolver_strand_.reset(
6363
newboost::asio::io_service::strand(service_));
6464
if (!service)
65-
lifetime_thread_.reset(newboost::thread(
66-
boost::bind(&boost::asio::io_service::run, &service_)));
65+
lifetime_thread_.reset(newstd::thread([this] () { service_.run(); }));
6766
}
6867

6968
~async_client()throw() =default;
@@ -93,7 +92,7 @@ struct async_client
9392
boost::asio::io_service& service_;
9493
resolver_type resolver_;
9594
boost::shared_ptr<boost::asio::io_service::work> sentinel_;
96-
boost::shared_ptr<boost::thread> lifetime_thread_;
95+
boost::shared_ptr<std::thread> lifetime_thread_;
9796
optional<string_type> certificate_filename_;
9897
optional<string_type> verify_path_;
9998
optional<string_type> certificate_file_;

‎libs/network/test/http/server_async_run_stop_concurrency.cpp‎

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#include<thread>
2+
#include<chrono>
13
#include<boost/network/include/http/server.hpp>
2-
#include<boost/thread.hpp>
34

45
namespacehttp= boost::network::http;
56
namespaceutil= boost::network::utils;
@@ -23,7 +24,7 @@ int main(int, char*[]) {
2324
#defineASYNC_SERVER_TEST_CONFIG \
2425
options.address("127.0.0.1").port("8007").reuse_address(true)
2526

26-
#defineASYNC_SERVER_SLEEP_TIMEboost::posix_time::milliseconds(100)
27+
#defineASYNC_SERVER_SLEEP_TIMEstd::chrono::milliseconds(100)
2728

2829
// stop from main thread
2930
{
@@ -39,9 +40,9 @@ int main(int, char*[]) {
3940
async_server::optionsoptions(async_handler);
4041
async_serverserver_instance(ASYNC_SERVER_TEST_CONFIG);
4142

42-
boost::threadrunning_thread(
43+
std::threadrunning_thread(
4344
boost::bind(&async_server::run, &server_instance));
44-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
45+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
4546

4647
server_instance.stop();
4748
running_thread.join();
@@ -53,13 +54,13 @@ int main(int, char*[]) {
5354
async_server::optionsoptions(async_handler);
5455
async_serverserver_instance(ASYNC_SERVER_TEST_CONFIG);
5556

56-
boost::threadrunning_thread(
57+
std::threadrunning_thread(
5758
boost::bind(&async_server::run, &server_instance));
58-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
59+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
5960

60-
boost::threadstopping_thread(
61+
std::threadstopping_thread(
6162
boost::bind(&async_server::stop, &server_instance));
62-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
63+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
6364

6465
stopping_thread.join();
6566
running_thread.join();
@@ -71,21 +72,21 @@ int main(int, char*[]) {
7172
async_server::optionsoptions(async_handler);
7273
async_serverserver_instance(ASYNC_SERVER_TEST_CONFIG);
7374

74-
boost::threadrunning_thread(
75+
std::threadrunning_thread(
7576
boost::bind(&async_server::run, &server_instance));
76-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
77+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
7778

78-
boost::threadstopping_thread(
79+
std::threadstopping_thread(
7980
boost::bind(&async_server::stop, &server_instance));
80-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
81+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
8182

82-
boost::threadsecond_running_thread(
83+
std::threadsecond_running_thread(
8384
boost::bind(&async_server::run, &server_instance));
84-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
85+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
8586

86-
boost::threadsecond_stopping_thread(
87+
std::threadsecond_stopping_thread(
8788
boost::bind(&async_server::stop, &server_instance));
88-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
89+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
8990

9091
stopping_thread.join();
9192
running_thread.join();
@@ -99,17 +100,17 @@ int main(int, char*[]) {
99100
async_server::optionsoptions(async_handler);
100101
async_serverserver_instance(ASYNC_SERVER_TEST_CONFIG);
101102

102-
boost::threadrunning_thread(
103+
std::threadrunning_thread(
103104
boost::bind(&async_server::run, &server_instance));
104-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
105+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
105106

106-
boost::threadsecond_running_thread(
107+
std::threadsecond_running_thread(
107108
boost::bind(&async_server::run, &server_instance));
108-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
109+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
109110

110-
boost::threadstopping_thread(
111+
std::threadstopping_thread(
111112
boost::bind(&async_server::stop, &server_instance));
112-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
113+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
113114

114115
stopping_thread.join();
115116
running_thread.join();
@@ -122,17 +123,17 @@ int main(int, char*[]) {
122123
async_server::optionsoptions(async_handler);
123124
async_serverserver_instance(ASYNC_SERVER_TEST_CONFIG);
124125

125-
boost::threadrunning_thread(
126+
std::threadrunning_thread(
126127
boost::bind(&async_server::run, &server_instance));
127-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
128+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
128129

129-
boost::threadstopping_thread(
130+
std::threadstopping_thread(
130131
boost::bind(&async_server::stop, &server_instance));
131-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
132+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
132133

133-
boost::threadsecond_stopping_thread(
134+
std::threadsecond_stopping_thread(
134135
boost::bind(&async_server::stop, &server_instance));
135-
boost::this_thread::sleep(ASYNC_SERVER_SLEEP_TIME);
136+
std::this_thread::sleep_for(ASYNC_SERVER_SLEEP_TIME);
136137

137138
stopping_thread.join();
138139
second_stopping_thread.join();

‎libs/network/test/uri/uri_test.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include<boost/network/uri/uri.hpp>
1212
#include<boost/network/uri/uri_io.hpp>
1313
#include<boost/range/algorithm/equal.hpp>
14-
#include<boost/scoped_ptr.hpp>
14+
#include<memory>
1515
#include<map>
1616
#include<set>
1717
#include<boost/unordered_set.hpp>
@@ -516,7 +516,7 @@ TEST(URITest, from_file) {
516516

517517
TEST(URITest, issue_104_test) {
518518
// https://github.com/cpp-netlib/cpp-netlib/issues/104
519-
boost::scoped_ptr<uri::uri>instance(newuri::uri("http://www.example.com/"));
519+
std::unique_ptr<uri::uri>instance(newuri::uri("http://www.example.com/"));
520520
uri::uri copy = *instance;
521521
instance.reset();
522522
EXPECT_EQ("http",uri::scheme(copy));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp