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

Commit5a369fc

Browse files
committed
Merge pull request#230 from torbjoernk/remove-boost-bindshrd
Replacing boost::bind and boost::enable_shared_form_this by std counterparts
2 parents7af8275 +358a035 commit5a369fc

File tree

15 files changed

+63
-64
lines changed

15 files changed

+63
-64
lines changed

‎concurrency/test/thread_pool_test.cpp‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
#include<gtest/gtest.h>
1010
#include<network/concurrency/thread_pool.hpp>
11-
#include<boost/bind.hpp>
11+
// #include <boost/bind.hpp>
12+
#include<functional>
1213

1314
using network::concurrency::thread_pool;
1415

@@ -37,8 +38,8 @@ TEST(concurrency_test, post_work) {
3738
foo instance;
3839
{
3940
thread_pool pool;
40-
ASSERT_NO_THROW(pool.post(boost::bind(&foo::bar, &instance,1)));
41-
ASSERT_NO_THROW(pool.post(boost::bind(&foo::bar, &instance,2)));
41+
ASSERT_NO_THROW(pool.post(std::bind(&foo::bar, &instance,1)));
42+
ASSERT_NO_THROW(pool.post(std::bind(&foo::bar, &instance,2)));
4243
// require that pool is destroyed here, RAII baby
4344
}
4445
ASSERT_EQ(instance.val(),3);

‎contrib/http_examples/http/fileserver.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct file_cache {
101101

102102
};
103103

104-
structconnection_handler :boost::enable_shared_from_this<connection_handler> {
104+
structconnection_handler :std::enable_shared_from_this<connection_handler> {
105105
explicitconnection_handler(file_cache& cache) : file_cache_(cache) {}
106106

107107
voidoperator()(std::stringconst& path,
@@ -143,7 +143,7 @@ struct connection_handler : boost::enable_shared_from_this<connection_handler> {
143143
connection->write(boost::asio::const_buffers_1(
144144
static_cast<charconst*>(mmaped_region.first) + offset,
145145
rightmost_bound),
146-
boost::bind(&connection_handler::handle_chunk,
146+
std::bind(&connection_handler::handle_chunk,
147147
connection_handler::shared_from_this(),
148148
mmaped_region,
149149
rightmost_bound,

‎http/src/network/protocol/http/client/connection/async_normal.ipp‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,18 @@ struct http_async_connection_pimpl
246246
boost::system::error_codeconst& ec,
247247
std::size_t bytes_transferred) {
248248
NETWORK_MESSAGE("http_async_connection_pimpl::handle_received_data(...)");
249+
#ifdef NETWORK_ENABLE_HTTPS
249250
// Okay, there's some weirdness with Boost.Asio's handling of SSL errors
250251
// so we need to do some acrobatics to make sure that we're handling the
251252
// short-read errors correctly. This is such a PITA that we have to deal
252253
// with this here.
253-
staticlong short_read_error =335544539;
254+
constexprstaticlong short_read_error =335544539;
254255
bool is_short_read_error =
255-
#ifdef NETWORK_ENABLE_HTTPS
256-
ec.category() == boost::asio::error::ssl_category &&
257-
ec.value() == short_read_error
256+
(ec.category() == boost::asio::error::ssl_category) &&
257+
(ec.value() == short_read_error);
258258
#else
259-
false
259+
constexprbool is_short_read_error =false;
260260
#endif
261-
;
262261
if (!ec || ec == boost::asio::error::eof || is_short_read_error) {
263262
NETWORK_MESSAGE("processing data chunk, no error encountered so far...");
264263
boost::logic::tribool parsed_ok;

‎http/src/network/protocol/http/client/connection/connection_delegate_factory.hpp‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ struct connection_delegate_factory {
3030
virtual~connection_delegate_factory();
3131

3232
private:
33-
connection_delegate_factory(connection_delegate_factoryconst&);// = delete
34-
connection_delegate_factory&operator=(
35-
connection_delegate_factory);// = delete
33+
connection_delegate_factory(connection_delegate_factoryconst &) =delete;
34+
connection_delegate_factory &operator=(connection_delegate_factory) =delete;
3635
};
3736

3837
}// namespace http

‎http/src/network/protocol/http/client/connection/connection_delegate_factory.ipp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ connection_delegate_factory::connection_delegate_ptr connection_delegate_factory
3333
if (https) {
3434
#ifdef NETWORK_ENABLE_HTTPS
3535
NETWORK_MESSAGE("creating an SSL delegate");
36-
delegate.reset(newssl_delegate(service, options));
36+
std::shared_ptr<ssl_delegate>delegate_ptr(newssl_delegate(service, options));
37+
delegate =std::move(delegate_ptr);
3738
#else
3839
NETWORK_MESSAGE("creating an SSL delegate, but not supported");
3940
BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported."));

‎http/src/network/protocol/http/client/connection/normal_delegate.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ struct normal_delegate : connection_delegate {
4141
boost::asio::io_service& service_;
4242
std::unique_ptr<boost::asio::ip::tcp::socket> socket_;
4343

44-
normal_delegate(normal_delegateconst&);//= delete
45-
normal_delegate&operator=(normal_delegate);//= delete
44+
normal_delegate(normal_delegateconst&)=delete;
45+
normal_delegate&operator=(normal_delegate)=delete;
4646
};
4747

4848
}// namespace http

‎http/src/network/protocol/http/client/connection/ssl_delegate.hpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include<boost/asio/ssl.hpp>
1212
#include<network/protocol/http/client/connection/connection_delegate.hpp>
1313
#include<network/protocol/http/client/options.hpp>
14-
#include<boost/enable_shared_from_this.hpp>
1514

1615
namespaceboost {
1716
namespaceasio {
@@ -23,7 +22,7 @@ namespace network {
2322
namespacehttp {
2423

2524
structssl_delegate : connection_delegate,
26-
boost::enable_shared_from_this<ssl_delegate> {
25+
std::enable_shared_from_this<ssl_delegate> {
2726
ssl_delegate(boost::asio::io_service& service, client_optionsconst& options);
2827

2928
virtualvoidconnect(

‎http/src/network/protocol/http/client/connection/ssl_delegate.ipp‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include<network/protocol/http/client/options.hpp>
1111
#include<network/protocol/http/client/connection/ssl_delegate.hpp>
1212
#include<boost/asio/placeholders.hpp>
13-
#include<functional>
1413
#include<network/detail/debug.hpp>
1514

1615
network::http::ssl_delegate::ssl_delegate(boost::asio::io_service& service,
@@ -48,8 +47,7 @@ void network::http::ssl_delegate::connect(
4847
}else {
4948
NETWORK_MESSAGE("not verifying peer");
5049
context_->set_default_verify_paths();
51-
context_->set_verify_mode(boost::asio::ssl::context::verify_peer);
52-
context_->set_verify_callback(boost::asio::ssl::rfc2818_verification(host));
50+
context_->set_verify_mode(boost::asio::ssl::context::verify_none);
5351
}
5452
socket_.reset(new boost::asio::ssl::stream<
5553
boost::asio::ip::tcp::socket>(service_, *context_));

‎http/src/network/protocol/http/policies/async_connection.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include<boost/shared_ptr.hpp>
1414
#include<boost/lexical_cast.hpp>
1515
#include<boost/cstdint.hpp>
16-
#include<boost/enable_shared_from_this.hpp>
16+
//#include <boost/enable_shared_from_this.hpp>
1717
#include<boost/tuple/tuple.hpp>
1818
#include<functional>
1919
#include<functional>
@@ -47,7 +47,7 @@ struct simple_async_connection_manager : connection_manager {
4747
structhttp_1_1_async_connection;
4848

4949
structhttp_1_1_async_connection_manager : connection_manager,
50-
enable_shared_from_this<http_1_1_async_connection_manager> {
50+
std::enable_shared_from_this<http_1_1_async_connection_manager> {
5151
http_1_1_async_connection_manager(bool cache_resolved,
5252
bool follow_redirects,
5353
optional<std::string> openssl_certificate,

‎http/src/network/protocol/http/server/connection/async.hpp‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
#include<vector>
3333
#include<iterator>
3434
#include<mutex>
35-
#include<boost/bind.hpp>
35+
// #include <boost/bind.hpp>
36+
#include<functional>
3637
#include<network/constants.hpp>
3738

3839
#ifndef NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE
@@ -213,7 +214,7 @@ class async_server_connection
213214
}
214215

215216
write_headers_only(
216-
boost::bind(&async_server_connection::do_nothing,
217+
std::bind(&async_server_connection::do_nothing,
217218
async_server_connection::shared_from_this()));
218219
}
219220

@@ -279,7 +280,7 @@ class async_server_connection
279280
input_range input =boost::make_iterator_range(new_start,
280281
read_buffer_.end());
281282
thread_pool()
282-
.post(boost::bind(callback,
283+
.post(std::bind(callback,
283284
input,
284285
boost::system::error_code(),
285286
std::distance(new_start, data_end),
@@ -290,7 +291,7 @@ class async_server_connection
290291

291292
socket().async_read_some(
292293
boost::asio::buffer(read_buffer_),
293-
strand.wrap(boost::bind(&async_server_connection::wrap_read_handler,
294+
strand.wrap(std::bind(&async_server_connection::wrap_read_handler,
294295
async_server_connection::shared_from_this(),
295296
callback,
296297
boost::asio::placeholders::error,
@@ -315,7 +316,7 @@ class async_server_connection
315316
data_end = read_buffer_.begin();
316317
std::advance(data_end, bytes_transferred);
317318
thread_pool()
318-
.post(boost::bind(callback,
319+
.post(std::bind(callback,
319320
boost::make_iterator_range(data_start, data_end),
320321
ec,
321322
bytes_transferred,
@@ -371,7 +372,7 @@ class async_server_connection
371372
voidread_more(state_t state) {
372373
socket_.async_read_some(
373374
boost::asio::buffer(read_buffer_),
374-
strand.wrap(boost::bind(&async_server_connection::handle_read_data,
375+
strand.wrap(std::bind(&async_server_connection::handle_read_data,
375376
async_server_connection::shared_from_this(),
376377
state,
377378
boost::asio::placeholders::error,
@@ -473,7 +474,7 @@ class async_server_connection
473474
}
474475
new_start =boost::end(result_range);
475476
thread_pool()
476-
.post(boost::bind(handler,
477+
.post(std::bind(handler,
477478
boost::cref(request_),
478479
async_server_connection::shared_from_this()));
479480
return;
@@ -502,7 +503,7 @@ class async_server_connection
502503
boost::asio::async_write(
503504
socket(),
504505
boost::asio::buffer(bad_request,strlen(bad_request)),
505-
strand.wrap(boost::bind(&async_server_connection::client_error_sent,
506+
strand.wrap(std::bind(&async_server_connection::client_error_sent,
506507
async_server_connection::shared_from_this(),
507508
boost::asio::placeholders::error,
508509
boost::asio::placeholders::bytes_transferred)));
@@ -528,7 +529,7 @@ class async_server_connection
528529
boost::asio::async_write(
529530
socket(),
530531
headers_buffer,
531-
strand.wrap(boost::bind(&async_server_connection::handle_write_headers,
532+
strand.wrap(std::bind(&async_server_connection::handle_write_headers,
532533
async_server_connection::shared_from_this(),
533534
callback,
534535
boost::asio::placeholders::error,
@@ -561,7 +562,7 @@ class async_server_connection
561562
boost::system::error_codeconst& ec,
562563
std::size_t bytes_transferred) {
563564
// we want to forget the temporaries and buffers
564-
thread_pool().post(boost::bind(callback, ec));
565+
thread_pool().post(std::bind(callback, ec));
565566
}
566567

567568
template<classRange>
@@ -621,7 +622,7 @@ class async_server_connection
621622
std::function<void(boost::system::error_code)> callback_function = callback;
622623

623624
std::function<void()> continuation =
624-
boost::bind(
625+
std::bind(
625626
&async_server_connection::template write_vec_impl<
626627
ConstBufferSeq,
627628
std::function<void(
@@ -643,7 +644,7 @@ class async_server_connection
643644
boost::asio::async_write(
644645
socket_,
645646
seq,
646-
boost::bind(&async_server_connection::handle_write,
647+
std::bind(&async_server_connection::handle_write,
647648
async_server_connection::shared_from_this(),
648649
callback_function,
649650
temporaries,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp