Remove placeholders (API Change)

This commit is contained in:
Vinnie Falco
2017-05-10 13:08:11 -07:00
parent 4799fc15a1
commit 7d8e40537a
13 changed files with 20 additions and 67 deletions

View File

@ -5,6 +5,7 @@ Version 41
API Changes
* Return http::error::end_of_stream on HTTP read eof
* Remove placeholders
--------------------------------------------------------------------------------

View File

@ -14,11 +14,11 @@
#include <beast/http.hpp>
#include <beast/core/handler_helpers.hpp>
#include <beast/core/handler_ptr.hpp>
#include <beast/core/placeholders.hpp>
#include <beast/core/multi_buffer.hpp>
#include <boost/asio.hpp>
#include <cstddef>
#include <cstdio>
#include <functional>
#include <iostream>
#include <memory>
#include <mutex>
@ -58,7 +58,7 @@ public:
boost::asio::socket_base::max_connections);
acceptor_.async_accept(sock_,
std::bind(&http_async_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
thread_.reserve(threads);
for(std::size_t i = 0; i < threads; ++i)
thread_.emplace_back(
@ -218,7 +218,7 @@ private:
{
async_read(sock_, sb_, req_, strand_.wrap(
std::bind(&peer::on_read, shared_from_this(),
asio::placeholders::error)));
std::placeholders::_1)));
}
void on_read(error_code const& ec)
@ -241,7 +241,7 @@ private:
prepare(res);
async_write(sock_, std::move(res),
std::bind(&peer::on_write, shared_from_this(),
asio::placeholders::error));
std::placeholders::_1));
return;
}
try
@ -256,7 +256,7 @@ private:
prepare(res);
async_write(sock_, std::move(res),
std::bind(&peer::on_write, shared_from_this(),
asio::placeholders::error));
std::placeholders::_1));
}
catch(std::exception const& e)
{
@ -271,7 +271,7 @@ private:
prepare(res);
async_write(sock_, std::move(res),
std::bind(&peer::on_write, shared_from_this(),
asio::placeholders::error));
std::placeholders::_1));
}
}
@ -312,7 +312,7 @@ private:
socket_type sock(std::move(sock_));
acceptor_.async_accept(sock_,
std::bind(&http_async_server::on_accept, this,
asio::placeholders::error));
std::placeholders::_1));
std::make_shared<peer>(std::move(sock), *this)->run();
}
};

View File

@ -12,7 +12,6 @@
#include "mime_type.hpp"
#include <beast/http.hpp>
#include <beast/core/placeholders.hpp>
#include <beast/core/multi_buffer.hpp>
#include <boost/asio.hpp>
#include <cstdint>
@ -59,7 +58,7 @@ public:
boost::asio::socket_base::max_connections);
acceptor_.async_accept(sock_,
std::bind(&http_sync_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
thread_ = std::thread{[&]{ ios_.run(); }};
}
@ -143,7 +142,7 @@ private:
std::thread{lambda{++id_, *this, std::move(sock_)}}.detach();
acceptor_.async_accept(sock_,
std::bind(&http_sync_server::on_accept, this,
asio::placeholders::error));
std::placeholders::_1));
}
void

View File

@ -8,7 +8,6 @@
#ifndef WEBSOCKET_ASYNC_ECHO_SERVER_HPP
#define WEBSOCKET_ASYNC_ECHO_SERVER_HPP
#include <beast/core/placeholders.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/websocket/stream.hpp>
#include <boost/lexical_cast.hpp>
@ -202,7 +201,7 @@ public:
return fail("listen", ec);
acceptor_.async_accept(sock_, ep_,
std::bind(&async_echo_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
}
private:
@ -351,7 +350,7 @@ private:
peer{*this, ep_, std::move(sock_)};
acceptor_.async_accept(sock_, ep_,
std::bind(&async_echo_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
}
};

View File

@ -8,7 +8,6 @@
#ifndef WEBSOCKET_SYNC_ECHO_SERVER_HPP
#define WEBSOCKET_SYNC_ECHO_SERVER_HPP
#include <beast/core/placeholders.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/websocket.hpp>
#include <boost/lexical_cast.hpp>
@ -191,7 +190,7 @@ public:
return fail("listen", ec);
acceptor_.async_accept(sock_, ep_,
std::bind(&sync_echo_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
thread_ = std::thread{[&]{ ios_.run(); }};
}
@ -259,7 +258,7 @@ private:
std::thread{lambda{*this, ep_, std::move(sock_)}}.detach();
acceptor_.async_accept(sock_, ep_,
std::bind(&sync_echo_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
}
void

View File

@ -25,7 +25,6 @@
#include <beast/core/handler_ptr.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/core/ostream.hpp>
#include <beast/core/placeholders.hpp>
#include <beast/core/prepare_buffers.hpp>
#include <beast/core/static_buffer.hpp>
#include <beast/core/static_string.hpp>

View File

@ -1,30 +0,0 @@
//
// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BEAST_PLACEHOLDERS_HPP
#define BEAST_PLACEHOLDERS_HPP
#include <beast/config.hpp>
#include <functional>
namespace beast {
namespace asio {
namespace placeholders {
// asio placeholders that work with std::bind
namespace {
static auto const error (std::placeholders::_1);
static auto const bytes_transferred (std::placeholders::_2);
static auto const iterator (std::placeholders::_2);
static auto const signal_number (std::placeholders::_2);
}
} // placeholders
} // asio
} // beast
#endif

View File

@ -31,7 +31,6 @@ unit-test core-tests :
core/handler_ptr.cpp
core/multi_buffer.cpp
core/ostream.cpp
core/placeholders.cpp
core/prepare_buffer.cpp
core/prepare_buffers.cpp
core/static_buffer.cpp

View File

@ -24,7 +24,6 @@ add_executable (core-tests
handler_ptr.cpp
multi_buffer.cpp
ostream.cpp
placeholders.cpp
prepare_buffer.cpp
prepare_buffers.cpp
static_buffer.cpp

View File

@ -1,9 +0,0 @@
//
// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Test that header file is self-contained.
#include <beast/core/placeholders.hpp>

View File

@ -8,7 +8,6 @@
#ifndef WEBSOCKET_ASYNC_SSL_ECHO_SERVER_HPP
#define WEBSOCKET_ASYNC_SSL_ECHO_SERVER_HPP
#include <beast/core/placeholders.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/websocket/ssl.hpp>
#include <beast/websocket/stream.hpp>
@ -141,7 +140,7 @@ public:
return fail("listen", ec);
acceptor_.async_accept(sock_, ep_,
std::bind(&async_ssl_echo_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
}
private:
@ -299,7 +298,7 @@ private:
connection{*this, ep_, std::move(sock_)}.run();
acceptor_.async_accept(sock_, ep_,
std::bind(&async_ssl_echo_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
}
};

View File

@ -8,7 +8,6 @@
#ifndef BEAST_WEBSOCKET_ASYNC_ECHO_SERVER_HPP
#define BEAST_WEBSOCKET_ASYNC_ECHO_SERVER_HPP
#include <beast/core/placeholders.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/websocket/stream.hpp>
#include <boost/lexical_cast.hpp>
@ -202,7 +201,7 @@ public:
return fail("listen", ec);
acceptor_.async_accept(sock_, ep_,
std::bind(&async_echo_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
}
private:
@ -405,7 +404,7 @@ private:
peer{*this, ep_, std::move(sock_)};
acceptor_.async_accept(sock_, ep_,
std::bind(&async_echo_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
}
};

View File

@ -8,7 +8,6 @@
#ifndef BEAST_WEBSOCKET_SYNC_ECHO_SERVER_HPP
#define BEAST_WEBSOCKET_SYNC_ECHO_SERVER_HPP
#include <beast/core/placeholders.hpp>
#include <beast/core/multi_buffer.hpp>
#include <beast/websocket.hpp>
#include <boost/lexical_cast.hpp>
@ -191,7 +190,7 @@ public:
return fail("listen", ec);
acceptor_.async_accept(sock_, ep_,
std::bind(&sync_echo_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
thread_ = std::thread{[&]{ ios_.run(); }};
}
@ -259,7 +258,7 @@ private:
std::thread{lambda{*this, ep_, std::move(sock_)}}.detach();
acceptor_.async_accept(sock_, ep_,
std::bind(&sync_echo_server::on_accept, this,
beast::asio::placeholders::error));
std::placeholders::_1));
}
template<class DynamicBuffer, std::size_t N>