mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Reduce requirements to C++11 only
This commit is contained in:
@@ -69,7 +69,7 @@ struct file_body
|
||||
size_ = boost::filesystem::file_size(path_);
|
||||
}
|
||||
|
||||
auto
|
||||
std::size_t
|
||||
content_length() const
|
||||
{
|
||||
return size_;
|
||||
|
||||
@@ -96,15 +96,12 @@ private:
|
||||
|
||||
explicit
|
||||
peer(socket_type&& sock, std::string const& root)
|
||||
: id_([]
|
||||
{
|
||||
static int n = 0;
|
||||
return ++n;
|
||||
}())
|
||||
, stream_(std::move(sock))
|
||||
: stream_(std::move(sock))
|
||||
, strand_(stream_.get_io_service())
|
||||
, root_(root)
|
||||
{
|
||||
static int n = 0;
|
||||
id_ = ++n;
|
||||
}
|
||||
|
||||
void run()
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define BEAST_HTTP_STREAM_H_INCLUDED
|
||||
|
||||
#include <beast/http.hpp>
|
||||
#include <beast/async_completion.hpp>
|
||||
#include <beast/basic_streambuf.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/intrusive/list.hpp>
|
||||
@@ -94,7 +95,7 @@ class stream : public detail::stream_base
|
||||
public:
|
||||
/// The type of the next layer.
|
||||
using next_layer_type =
|
||||
std::remove_reference_t<NextLayer>;
|
||||
typename std::remove_reference<NextLayer>::type;
|
||||
|
||||
/// The type of the lowest layer.
|
||||
using lowest_layer_type =
|
||||
@@ -335,7 +336,8 @@ public:
|
||||
#if GENERATING_DOCS
|
||||
void_or_deduced
|
||||
#else
|
||||
auto
|
||||
typename async_completion<
|
||||
ReadHandler, void(error_code)>::result_type
|
||||
#endif
|
||||
async_read(message<isRequest, Body, Headers>& msg,
|
||||
ReadHandler&& handler);
|
||||
@@ -429,7 +431,8 @@ public:
|
||||
#if GENERATING_DOCS
|
||||
void_or_deduced
|
||||
#else
|
||||
auto
|
||||
typename async_completion<
|
||||
WriteHandler, void(error_code)>::result_type
|
||||
#endif
|
||||
async_write(message<isRequest, Body, Headers> const& msg,
|
||||
WriteHandler&& handler);
|
||||
@@ -467,7 +470,8 @@ public:
|
||||
#if GENERATING_DOCS
|
||||
void_or_deduced
|
||||
#else
|
||||
auto
|
||||
typename async_completion<
|
||||
WriteHandler, void(error_code)>::result_type
|
||||
#endif
|
||||
async_write(message<isRequest, Body, Headers>&& msg,
|
||||
WriteHandler&& handler);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#ifndef BEAST_HTTP_STREAM_IPP_INCLUDED
|
||||
#define BEAST_HTTP_STREAM_IPP_INCLUDED
|
||||
|
||||
#include <beast/async_completion.hpp>
|
||||
#include <beast/bind_handler.hpp>
|
||||
#include <beast/handler_alloc.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
@@ -78,7 +77,7 @@ public:
|
||||
void operator()(error_code const& ec, bool again = true);
|
||||
|
||||
friend
|
||||
auto asio_handler_allocate(
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, read_op* op)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::
|
||||
@@ -86,7 +85,7 @@ public:
|
||||
}
|
||||
|
||||
friend
|
||||
auto asio_handler_deallocate(
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, read_op* op)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::
|
||||
@@ -94,14 +93,14 @@ public:
|
||||
}
|
||||
|
||||
friend
|
||||
auto asio_handler_is_continuation(read_op* op)
|
||||
bool asio_handler_is_continuation(read_op* op)
|
||||
{
|
||||
return op->d_->cont;
|
||||
}
|
||||
|
||||
template <class Function>
|
||||
friend
|
||||
auto asio_handler_invoke(Function&& f, read_op* op)
|
||||
void asio_handler_invoke(Function&& f, read_op* op)
|
||||
{
|
||||
return boost_asio_handler_invoke_helpers::
|
||||
invoke(f, op->d_->h);
|
||||
@@ -198,7 +197,7 @@ public:
|
||||
void operator()(error_code const& ec, bool again = true);
|
||||
|
||||
friend
|
||||
auto asio_handler_allocate(
|
||||
void* asio_handler_allocate(
|
||||
std::size_t size, write_op* op)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::
|
||||
@@ -206,7 +205,7 @@ public:
|
||||
}
|
||||
|
||||
friend
|
||||
auto asio_handler_deallocate(
|
||||
void asio_handler_deallocate(
|
||||
void* p, std::size_t size, write_op* op)
|
||||
{
|
||||
return boost_asio_handler_alloc_helpers::
|
||||
@@ -214,14 +213,14 @@ public:
|
||||
}
|
||||
|
||||
friend
|
||||
auto asio_handler_is_continuation(write_op* op)
|
||||
bool asio_handler_is_continuation(write_op* op)
|
||||
{
|
||||
return op->d_->cont;
|
||||
}
|
||||
|
||||
template <class Function>
|
||||
friend
|
||||
auto asio_handler_invoke(Function&& f, write_op* op)
|
||||
void asio_handler_invoke(Function&& f, write_op* op)
|
||||
{
|
||||
return boost_asio_handler_invoke_helpers::
|
||||
invoke(f, op->d_->h);
|
||||
@@ -319,7 +318,9 @@ template<bool isRequest, class Body, class Headers,
|
||||
auto
|
||||
stream<NextLayer, Allocator>::
|
||||
async_read(message<isRequest, Body, Headers>& msg,
|
||||
ReadHandler&& handler)
|
||||
ReadHandler&& handler) ->
|
||||
typename async_completion<
|
||||
ReadHandler, void(error_code)>::result_type
|
||||
{
|
||||
async_completion<
|
||||
ReadHandler, void(error_code)
|
||||
@@ -346,7 +347,9 @@ template<bool isRequest, class Body, class Headers,
|
||||
auto
|
||||
stream<NextLayer, Allocator>::
|
||||
async_write(message<isRequest, Body, Headers> const& msg,
|
||||
WriteHandler&& handler)
|
||||
WriteHandler&& handler) ->
|
||||
typename async_completion<
|
||||
WriteHandler, void(error_code)>::result_type
|
||||
{
|
||||
async_completion<
|
||||
WriteHandler, void(error_code)> completion(handler);
|
||||
@@ -375,7 +378,9 @@ template<bool isRequest, class Body, class Headers,
|
||||
auto
|
||||
stream<NextLayer, Allocator>::
|
||||
async_write(message<isRequest, Body, Headers>&& msg,
|
||||
WriteHandler&& handler)
|
||||
WriteHandler&& handler) ->
|
||||
typename async_completion<
|
||||
WriteHandler, void(error_code)>::result_type
|
||||
{
|
||||
async_completion<
|
||||
WriteHandler, void(error_code)> completion(handler);
|
||||
|
||||
@@ -94,6 +94,28 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
struct lambda
|
||||
{
|
||||
int id;
|
||||
http_sync_server& self;
|
||||
socket_type sock;
|
||||
boost::asio::io_service::work work;
|
||||
|
||||
lambda(int id_, http_sync_server& self_,
|
||||
socket_type&& sock_)
|
||||
: id(id_)
|
||||
, self(self_)
|
||||
, sock(std::move(sock_))
|
||||
, work(sock.get_io_service())
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
self.do_peer(id, std::move(sock));
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
on_accept(error_code ec)
|
||||
{
|
||||
@@ -101,16 +123,7 @@ public:
|
||||
return;
|
||||
maybe_throw(ec, "accept");
|
||||
static int id_ = 0;
|
||||
std::thread{
|
||||
[
|
||||
id = ++id_,
|
||||
this,
|
||||
sock = std::move(sock_),
|
||||
work = boost::asio::io_service::work{ios_}
|
||||
]() mutable
|
||||
{
|
||||
do_peer(id, std::move(sock));
|
||||
}}.detach();
|
||||
std::thread{lambda{++id_, *this, std::move(sock_)}}.detach();
|
||||
acceptor_.async_accept(sock_,
|
||||
std::bind(&http_sync_server::on_accept, this,
|
||||
asio::placeholders::error));
|
||||
|
||||
@@ -102,6 +102,28 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
struct lambda
|
||||
{
|
||||
int id;
|
||||
sync_echo_peer& self;
|
||||
socket_type sock;
|
||||
boost::asio::io_service::work work;
|
||||
|
||||
lambda(int id_, sync_echo_peer& self_,
|
||||
socket_type&& sock_)
|
||||
: id(id_)
|
||||
, self(self_)
|
||||
, sock(std::move(sock_))
|
||||
, work(sock.get_io_service())
|
||||
{
|
||||
}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
self.do_peer(id, std::move(sock));
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
on_accept(error_code ec)
|
||||
{
|
||||
@@ -109,16 +131,7 @@ private:
|
||||
return;
|
||||
maybe_throw(ec, "accept");
|
||||
static int id_ = 0;
|
||||
std::thread{
|
||||
[
|
||||
id = ++id_,
|
||||
this,
|
||||
sock = std::move(sock_),
|
||||
work = boost::asio::io_service::work{ios_}
|
||||
]() mutable
|
||||
{
|
||||
do_peer(id, std::move(sock));
|
||||
}}.detach();
|
||||
std::thread{lambda{++id_, *this, std::move(sock_)}}.detach();
|
||||
acceptor_.async_accept(sock_,
|
||||
std::bind(&sync_echo_peer::on_accept, this,
|
||||
beast::asio::placeholders::error));
|
||||
|
||||
Reference in New Issue
Block a user