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

Replacing boost::bind and boost::enable_shared_form_this by std counterparts#230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
deanberris merged 4 commits intocpp-netlib:masterfromtorbjoernk:remove-boost-bindshrd
Apr 14, 2013
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletionsconcurrency/test/thread_pool_test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,8 @@

#include<gtest/gtest.h>
#include<network/concurrency/thread_pool.hpp>
#include<boost/bind.hpp>
// #include <boost/bind.hpp>
#include<functional>

using network::concurrency::thread_pool;

Expand DownExpand Up@@ -37,8 +38,8 @@ TEST(concurrency_test, post_work) {
foo instance;
{
thread_pool pool;
ASSERT_NO_THROW(pool.post(boost::bind(&foo::bar, &instance,1)));
ASSERT_NO_THROW(pool.post(boost::bind(&foo::bar, &instance,2)));
ASSERT_NO_THROW(pool.post(std::bind(&foo::bar, &instance,1)));
ASSERT_NO_THROW(pool.post(std::bind(&foo::bar, &instance,2)));
// require that pool is destroyed here, RAII baby
}
ASSERT_EQ(instance.val(),3);
Expand Down
4 changes: 2 additions & 2 deletionscontrib/http_examples/http/fileserver.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -101,7 +101,7 @@ struct file_cache {

};

structconnection_handler :boost::enable_shared_from_this<connection_handler> {
structconnection_handler :std::enable_shared_from_this<connection_handler> {
explicitconnection_handler(file_cache& cache) : file_cache_(cache) {}

voidoperator()(std::stringconst& path,
Expand DownExpand Up@@ -143,7 +143,7 @@ struct connection_handler : boost::enable_shared_from_this<connection_handler> {
connection->write(boost::asio::const_buffers_1(
static_cast<charconst*>(mmaped_region.first) + offset,
rightmost_bound),
boost::bind(&connection_handler::handle_chunk,
std::bind(&connection_handler::handle_chunk,
connection_handler::shared_from_this(),
mmaped_region,
rightmost_bound,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -246,19 +246,18 @@ struct http_async_connection_pimpl
boost::system::error_code const& ec,
std::size_t bytes_transferred) {
NETWORK_MESSAGE("http_async_connection_pimpl::handle_received_data(...)");
#ifdef NETWORK_ENABLE_HTTPS
// Okay, there's some weirdness with Boost.Asio's handling of SSL errors
// so we need to do some acrobatics to make sure that we're handling the
// short-read errors correctly. This is such a PITA that we have to deal
// with this here.
static long short_read_error = 335544539;
constexprstatic long short_read_error = 335544539;
bool is_short_read_error =
#ifdef NETWORK_ENABLE_HTTPS
ec.category() == boost::asio::error::ssl_category &&
ec.value() == short_read_error
(ec.category() == boost::asio::error::ssl_category) &&
(ec.value() == short_read_error);
#else
false
constexpr bool is_short_read_error = false;
#endif
;
if (!ec || ec == boost::asio::error::eof || is_short_read_error) {
NETWORK_MESSAGE("processing data chunk, no error encountered so far...");
boost::logic::tribool parsed_ok;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,9 +30,8 @@ struct connection_delegate_factory {
virtual~connection_delegate_factory();

private:
connection_delegate_factory(connection_delegate_factoryconst&);// = delete
connection_delegate_factory&operator=(
connection_delegate_factory);// = delete
connection_delegate_factory(connection_delegate_factoryconst &) =delete;
connection_delegate_factory &operator=(connection_delegate_factory) =delete;
};

}// namespace http
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,8 @@ connection_delegate_factory::connection_delegate_ptr connection_delegate_factory
if (https) {
#ifdef NETWORK_ENABLE_HTTPS
NETWORK_MESSAGE("creating an SSL delegate");
delegate.reset(newssl_delegate(service, options));
std::shared_ptr<ssl_delegate>delegate_ptr(newssl_delegate(service, options));
delegate =std::move(delegate_ptr);
#else
NETWORK_MESSAGE("creating an SSL delegate, but not supported");
BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported."));
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,8 +41,8 @@ struct normal_delegate : connection_delegate {
boost::asio::io_service& service_;
std::unique_ptr<boost::asio::ip::tcp::socket> socket_;

normal_delegate(normal_delegateconst&);//= delete
normal_delegate&operator=(normal_delegate);//= delete
normal_delegate(normal_delegateconst&)=delete;
normal_delegate&operator=(normal_delegate)=delete;
};

}// namespace http
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@
#include<boost/asio/ssl.hpp>
#include<network/protocol/http/client/connection/connection_delegate.hpp>
#include<network/protocol/http/client/options.hpp>
#include<boost/enable_shared_from_this.hpp>

namespaceboost {
namespaceasio {
Expand All@@ -23,7 +22,7 @@ namespace network {
namespacehttp {

structssl_delegate : connection_delegate,
boost::enable_shared_from_this<ssl_delegate> {
std::enable_shared_from_this<ssl_delegate> {
ssl_delegate(boost::asio::io_service& service, client_optionsconst& options);

virtualvoidconnect(
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,6 @@
#include<network/protocol/http/client/options.hpp>
#include<network/protocol/http/client/connection/ssl_delegate.hpp>
#include<boost/asio/placeholders.hpp>
#include<functional>
#include<network/detail/debug.hpp>

network::http::ssl_delegate::ssl_delegate(boost::asio::io_service& service,
Expand DownExpand Up@@ -48,8 +47,7 @@ void network::http::ssl_delegate::connect(
}else {
NETWORK_MESSAGE("not verifying peer");
context_->set_default_verify_paths();
context_->set_verify_mode(boost::asio::ssl::context::verify_peer);
context_->set_verify_callback(boost::asio::ssl::rfc2818_verification(host));
context_->set_verify_mode(boost::asio::ssl::context::verify_none);
}
socket_.reset(new boost::asio::ssl::stream<
boost::asio::ip::tcp::socket>(service_, *context_));
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@
#include<boost/shared_ptr.hpp>
#include<boost/lexical_cast.hpp>
#include<boost/cstdint.hpp>
#include<boost/enable_shared_from_this.hpp>
//#include <boost/enable_shared_from_this.hpp>
#include<boost/tuple/tuple.hpp>
#include<functional>
#include<functional>
Expand DownExpand Up@@ -47,7 +47,7 @@ struct simple_async_connection_manager : connection_manager {
structhttp_1_1_async_connection;

structhttp_1_1_async_connection_manager : connection_manager,
enable_shared_from_this<http_1_1_async_connection_manager> {
std::enable_shared_from_this<http_1_1_async_connection_manager> {
http_1_1_async_connection_manager(bool cache_resolved,
bool follow_redirects,
optional<std::string> openssl_certificate,
Expand Down
25 changes: 13 additions & 12 deletionshttp/src/network/protocol/http/server/connection/async.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,7 +32,8 @@
#include<vector>
#include<iterator>
#include<mutex>
#include<boost/bind.hpp>
// #include <boost/bind.hpp>
#include<functional>
#include<network/constants.hpp>

#ifndef NETWORK_HTTP_SERVER_CONNECTION_HEADER_BUFFER_MAX_SIZE
Expand DownExpand Up@@ -213,7 +214,7 @@ class async_server_connection
}

write_headers_only(
boost::bind(&async_server_connection::do_nothing,
std::bind(&async_server_connection::do_nothing,
async_server_connection::shared_from_this()));
}

Expand DownExpand Up@@ -279,7 +280,7 @@ class async_server_connection
input_range input =boost::make_iterator_range(new_start,
read_buffer_.end());
thread_pool()
.post(boost::bind(callback,
.post(std::bind(callback,
input,
boost::system::error_code(),
std::distance(new_start, data_end),
Expand All@@ -290,7 +291,7 @@ class async_server_connection

socket().async_read_some(
boost::asio::buffer(read_buffer_),
strand.wrap(boost::bind(&async_server_connection::wrap_read_handler,
strand.wrap(std::bind(&async_server_connection::wrap_read_handler,
async_server_connection::shared_from_this(),
callback,
boost::asio::placeholders::error,
Expand All@@ -315,7 +316,7 @@ class async_server_connection
data_end = read_buffer_.begin();
std::advance(data_end, bytes_transferred);
thread_pool()
.post(boost::bind(callback,
.post(std::bind(callback,
boost::make_iterator_range(data_start, data_end),
ec,
bytes_transferred,
Expand DownExpand Up@@ -371,7 +372,7 @@ class async_server_connection
voidread_more(state_t state) {
socket_.async_read_some(
boost::asio::buffer(read_buffer_),
strand.wrap(boost::bind(&async_server_connection::handle_read_data,
strand.wrap(std::bind(&async_server_connection::handle_read_data,
async_server_connection::shared_from_this(),
state,
boost::asio::placeholders::error,
Expand DownExpand Up@@ -473,7 +474,7 @@ class async_server_connection
}
new_start =boost::end(result_range);
thread_pool()
.post(boost::bind(handler,
.post(std::bind(handler,
boost::cref(request_),
async_server_connection::shared_from_this()));
return;
Expand DownExpand Up@@ -502,7 +503,7 @@ class async_server_connection
boost::asio::async_write(
socket(),
boost::asio::buffer(bad_request,strlen(bad_request)),
strand.wrap(boost::bind(&async_server_connection::client_error_sent,
strand.wrap(std::bind(&async_server_connection::client_error_sent,
async_server_connection::shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred)));
Expand All@@ -528,7 +529,7 @@ class async_server_connection
boost::asio::async_write(
socket(),
headers_buffer,
strand.wrap(boost::bind(&async_server_connection::handle_write_headers,
strand.wrap(std::bind(&async_server_connection::handle_write_headers,
async_server_connection::shared_from_this(),
callback,
boost::asio::placeholders::error,
Expand DownExpand Up@@ -561,7 +562,7 @@ class async_server_connection
boost::system::error_codeconst& ec,
std::size_t bytes_transferred) {
// we want to forget the temporaries and buffers
thread_pool().post(boost::bind(callback, ec));
thread_pool().post(std::bind(callback, ec));
}

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

std::function<void()> continuation =
boost::bind(
std::bind(
&async_server_connection::template write_vec_impl<
ConstBufferSeq,
std::function<void(
Expand All@@ -643,7 +644,7 @@ class async_server_connection
boost::asio::async_write(
socket_,
seq,
boost::bind(&async_server_connection::handle_write,
std::bind(&async_server_connection::handle_write,
async_server_connection::shared_from_this(),
callback_function,
temporaries,
Expand Down
12 changes: 6 additions & 6 deletionshttp/src/network/protocol/http/server/connection/sync.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,7 @@

#include <utility>
#include <iterator>
#include <boost/enable_shared_from_this.hpp>
//#include <boost/enable_shared_from_this.hpp>
#include <network/constants.hpp>
#include <network/protocol/http/server/request_parser.hpp>
#include <network/protocol/http/request.hpp>
Expand DownExpand Up@@ -43,7 +43,7 @@ extern void parse_headers(
#endif

class sync_server_connection
: publicboost::enable_shared_from_this<sync_server_connection> {
: publicstd::enable_shared_from_this<sync_server_connection> {
public:
sync_server_connection(boost::asio::io_service& service,
std::function<void(request const&, response&)> handler)
Expand All@@ -64,7 +64,7 @@ class sync_server_connection
<< socket_.remote_endpoint().port();
request_.set_source(ip_stream.str());
socket_.async_read_some(boost::asio::buffer(read_buffer_),
wrapper_.wrap(boost::bind(
wrapper_.wrap(std::bind(
&sync_server_connection::handle_read_data,
sync_server_connection::shared_from_this(),
method,
Expand DownExpand Up@@ -196,7 +196,7 @@ class sync_server_connection
socket_,
response_buffers,
wrapper_.wrap(
boost::bind(&sync_server_connection::handle_write,
std::bind(&sync_server_connection::handle_write,
sync_server_connection::shared_from_this(),
boost::asio::placeholders::error)));
}
Expand DownExpand Up@@ -235,7 +235,7 @@ class sync_server_connection
socket(),
boost::asio::buffer(bad_request, strlen(bad_request)),
wrapper_.wrap(
boost::bind(&sync_server_connection::client_error_sent,
std::bind(&sync_server_connection::client_error_sent,
sync_server_connection::shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred)));
Expand All@@ -254,7 +254,7 @@ class sync_server_connection

void read_more(state_t state) {
socket_.async_read_some(boost::asio::buffer(read_buffer_),
wrapper_.wrap(boost::bind(
wrapper_.wrap(std::bind(
&sync_server_connection::handle_read_data,
sync_server_connection::shared_from_this(),
state,
Expand Down
2 changes: 1 addition & 1 deletionhttp/test/server_async_less_copy.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,7 +42,7 @@ struct async_hello_world {
connection->set_headers(boost::make_iterator_range(headers, headers +4));
std::vector<boost::asio::const_buffer> iovec;
iovec.push_back(boost::asio::const_buffer(hello_world,13));
connection->write(iovec,boost::bind(&async_hello_world::error,this, _1));
connection->write(iovec,std::bind(&async_hello_world::error,this, _1));
}

voiderror(boost::system::error_codeconst& ec) {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp