Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 14, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
replacing boost::bind by std::bind
boost::bind is still used in the test cases, which seem not affected by
this change (e.g. no further failures)
  • Loading branch information
torbjoernk committed Apr 13, 2013
commit a5cb1380d0bb9ce4b381b6665fede3915f72277a
7 changes: 4 additions & 3 deletions concurrency/test/thread_pool_test.cpp
Original file line number Diff line number Diff 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 Down Expand 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
2 changes: 1 addition & 1 deletion contrib/http_examples/http/fileserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ struct connection_handler : std::enable_shared_from_this<connection_handler> {
connection->write(boost::asio::const_buffers_1(
static_cast<char const*>(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
25 changes: 13 additions & 12 deletions http/src/network/protocol/http/server/connection/async.hpp
Original file line number Diff line number Diff 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 Down Expand 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 Down Expand 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 Down Expand Up @@ -371,7 +372,7 @@ class async_server_connection
void read_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 Down Expand 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 Down Expand 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 Down Expand Up @@ -561,7 +562,7 @@ class async_server_connection
boost::system::error_code const& 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 <class Range>
Expand Down Expand 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
8 changes: 4 additions & 4 deletions http/src/network/protocol/http/server/connection/sync.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 Down Expand 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 Down Expand 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