20#ifndef RIPPLE_SERVER_SERVERIMPL_H_INCLUDED
21#define RIPPLE_SERVER_SERVERIMPL_H_INCLUDED
23#include <xrpl/basics/chrono.h>
24#include <xrpl/beast/core/List.h>
25#include <xrpl/server/detail/Door.h>
26#include <xrpl/server/detail/io_list.h>
28#include <boost/asio.hpp>
29#include <boost/asio/executor_work_guard.hpp>
30#include <boost/asio/io_context.hpp>
80template <
class Handler>
91 boost::asio::strand<boost::asio::io_context::executor_type>
strand_;
93 boost::asio::io_context::executor_type>>
107 boost::asio::io_context& io_context,
130 boost::asio::io_context&
144template <
class Handler>
147 boost::asio::io_context& io_context,
151 , io_context_(io_context)
152 , strand_(
boost::asio::make_strand(io_context_))
153 , work_(
std::in_place,
boost::asio::make_work_guard(io_context_))
157template <
class Handler>
166template <
class Handler>
171 Throw<std::logic_error>(
"ports() on closed Server");
172 ports_.reserve(ports.
size());
175 for (
auto const& port : ports)
177 ports_.push_back(port);
178 auto& internalPort = ports_.back();
180 handler_, io_context_, internalPort, j_))
184 auto ep = sp->get_endpoint();
185 if (!internalPort.port)
186 internalPort.port = ep.port();
187 eps.
emplace(port.name, std::move(ep));
195template <
class Handler>
201 handler_.onStopped(*
this);
205template <
class Handler>
209 return ios_.closed();
A generic endpoint for log messages.
std::vector< std::weak_ptr< Door< Handler > > > list_
std::vector< Port > ports_
boost::asio::strand< boost::asio::io_context::executor_type > strand_
void close() override
Close the server.
std::array< std::size_t, 64 > hist_
boost::asio::io_context & get_io_context()
beast::Journal journal() override
Returns the Journal associated with the server.
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
static int ceil_log2(unsigned long long x)
boost::asio::io_context & io_context_
Endpoints ports(std::vector< Port > const &ports) override
Set the listening port settings.
ServerImpl(Handler &handler, boost::asio::io_context &io_context, beast::Journal journal)
virtual void close()=0
Close the server.
virtual Endpoints ports(std::vector< Port > const &v)=0
Set the listening port settings.
virtual ~Server()=default
Destroy the server.
virtual beast::Journal journal()=0
Returns the Journal associated with the server.
Manages a set of objects performing asynchronous I/O.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.