mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Refactor beast::asio:
* New tools for completion handlers: - wrap_handler provides composed io_service execution guarantees. - bind_handler rebinds arguments to handlers. - shared_handler type-erases any completion handler. - buffer_sequence type-erases templated BufferSequences - abstract_socket replaces Socket - socket_wrapper replaces SocketWrapper - beast::asio placeholders to work with std::bind * Removed obsolete classes and functions - AbstractHandler - ComposedAsyncOperation - SharedFunction - SharedHandler - SharedHandlerAllocator - SharedHandlerPtr - SharedHandlerType - SocketBase - SocketWrapperStrand - wrapHandler * Refactored classes to use new tools - abstract_socket - socket_wrapper - HandshakeDetector - HttpClientType * Miscellanous tidying - socket classes moved to beast::asio namespace - beast asio files provide their own namespace declaration. - Fix IsCallPossible conflicting template parameter name - Use <boost/get_pointer.hpp> for C++11 compatibility. - Remove extraneous include path from build environment.
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLE_PEERFINDER_TYPES_H_INCLUDED
|
||||
#define RIPPLE_PEERFINDER_TYPES_H_INCLUDED
|
||||
|
||||
#include "beast/beast/chrono/abstract_clock.h"
|
||||
#include "../../beast/beast/chrono/abstract_clock.h"
|
||||
|
||||
namespace ripple {
|
||||
namespace PeerFinder {
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "../../../beast/beast/asio/wrap_handler.h"
|
||||
#include "../../../beast/beast/asio/placeholders.h"
|
||||
|
||||
namespace ripple {
|
||||
namespace PeerFinder {
|
||||
|
||||
@@ -56,13 +59,14 @@ private:
|
||||
CheckerImp& m_owner;
|
||||
boost::asio::io_service& m_io_service;
|
||||
IP::Endpoint m_address;
|
||||
AbstractHandler <void (Result)> m_handler;
|
||||
asio::shared_handler <void (Result)> m_handler;
|
||||
socket_type m_socket;
|
||||
boost::system::error_code m_error;
|
||||
bool m_canAccept;
|
||||
|
||||
Request (CheckerImp& owner, boost::asio::io_service& io_service,
|
||||
IP::Endpoint const& address, AbstractHandler <void (Result)> handler)
|
||||
IP::Endpoint const& address, asio::shared_handler <
|
||||
void (Result)> const& handler)
|
||||
: m_owner (owner)
|
||||
, m_io_service (io_service)
|
||||
, m_address (address)
|
||||
@@ -73,9 +77,9 @@ private:
|
||||
m_owner.add (*this);
|
||||
|
||||
m_socket.async_connect (IPAddressConversion::to_asio_endpoint (
|
||||
m_address), wrapHandler (boost::bind (
|
||||
m_address), asio::wrap_handler (std::bind (
|
||||
&Request::handle_connect, Ptr(this),
|
||||
boost::asio::placeholders::error), m_handler));
|
||||
asio::placeholders::error), m_handler));
|
||||
}
|
||||
|
||||
~Request ()
|
||||
@@ -151,7 +155,7 @@ public:
|
||||
}
|
||||
|
||||
void async_test (IP::Endpoint const& endpoint,
|
||||
AbstractHandler <void (Result)> handler)
|
||||
asio::shared_handler <void (Result)> handler)
|
||||
{
|
||||
new Request (*this, m_io_service, endpoint, handler);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef RIPPLE_PEERFINDER_CHECKER_H_INCLUDED
|
||||
#define RIPPLE_PEERFINDER_CHECKER_H_INCLUDED
|
||||
|
||||
#include "../../../beast/beast/asio/shared_handler.h"
|
||||
|
||||
namespace ripple {
|
||||
namespace PeerFinder {
|
||||
|
||||
@@ -67,20 +69,9 @@ public:
|
||||
|
||||
/** Performs an async connection test on the specified endpoint.
|
||||
The port must be non-zero.
|
||||
Handler will be called with this signature:
|
||||
void (Result const& result);
|
||||
*/
|
||||
template <typename Handler>
|
||||
void async_test (IP::Endpoint const& endpoint,
|
||||
BEAST_MOVE_ARG(Handler) handler)
|
||||
{
|
||||
async_test (endpoint,
|
||||
AbstractHandler <void (Result)> (
|
||||
BEAST_MOVE_CAST(Handler)(handler)));
|
||||
}
|
||||
|
||||
virtual void async_test (IP::Endpoint const& endpoint,
|
||||
AbstractHandler <void (Result)> handler) = 0;
|
||||
asio::shared_handler <void (Result)> handler) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -47,12 +47,12 @@ private:
|
||||
{
|
||||
SerializedContext& m_context;
|
||||
ServiceQueue& m_queue;
|
||||
AbstractHandler <void (Checker::Result)> m_handler;
|
||||
asio::shared_handler <void (Checker::Result)> m_handler;
|
||||
|
||||
Handler (
|
||||
SerializedContext& context,
|
||||
ServiceQueue& queue,
|
||||
AbstractHandler <void (Checker::Result)> handler)
|
||||
asio::shared_handler <void (Checker::Result)> const& handler)
|
||||
: m_context (context)
|
||||
, m_queue (queue)
|
||||
, m_handler (handler)
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
}
|
||||
|
||||
void async_test (IP::Endpoint const& endpoint,
|
||||
AbstractHandler <void (Checker::Result)> handler)
|
||||
asio::shared_handler <void (Checker::Result)> handler)
|
||||
{
|
||||
m_checker->async_test (endpoint, Handler (
|
||||
m_context, m_queue, handler));
|
||||
|
||||
@@ -31,17 +31,17 @@
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "beast/modules/beast_core/system/BeforeBoost.h"
|
||||
#include "../beast/modules/beast_core/system/BeforeBoost.h"
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
#include "beast/modules/beast_sqdb/beast_sqdb.h"
|
||||
#include "beast/modules/beast_asio/beast_asio.h"
|
||||
#include "../beast/modules/beast_sqdb/beast_sqdb.h"
|
||||
#include "../beast/modules/beast_asio/beast_asio.h"
|
||||
|
||||
#include "beast/beast/cyclic_iterator.h"
|
||||
#include "beast/beast/boost/ErrorCode.h"
|
||||
#include "../beast/beast/cyclic_iterator.h"
|
||||
#include "../beast/beast/boost/ErrorCode.h"
|
||||
|
||||
#include "impl/iosformat.h" // VFALCO NOTE move to beast
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef RIPPLE_PEERFINDER_H_INCLUDED
|
||||
#define RIPPLE_PEERFINDER_H_INCLUDED
|
||||
|
||||
#include "beast/modules/beast_core/beast_core.h"
|
||||
#include "../beast/modules/beast_core/beast_core.h"
|
||||
|
||||
#include "../sitefiles/ripple_sitefiles.h"
|
||||
|
||||
|
||||
@@ -501,7 +501,7 @@ public:
|
||||
}
|
||||
|
||||
void async_test (IP::Endpoint const& address,
|
||||
AbstractHandler <void (Result)> handler)
|
||||
asio::shared_handler <void (Result)> handler)
|
||||
{
|
||||
Node* const node (m_network.find (address));
|
||||
Checker::Result result;
|
||||
|
||||
Reference in New Issue
Block a user